I have the following bash script...
#!/bin/bash # Delete JUNK temp folder if [ -d JUNK/FOLDER/PATH ] then rm -rf JUNK/FOLDER/PATH echo "Cleansed JUNK directory successfully!" /usr/bin/mail -s "JUNK folder deleted successfully" email@example.com <<< "Success!" else /usr/bin/mail -s "JUNK folder not found" firstname.lastname@example.org <<< "Success!" fi
I have it in my crontab as below
* * * * * /bin/sh /home1/ramnath/public_html/myscripts/deltemp.sh
Q1: Why is the script is not running? Is there an error? When I manually run the script in the terminal, I get an error:
Cleansed JUNK directory successfully!
myscripts/deltemp.sh: line 8: mail: command not found
NOTE: The issue is fixed. I just used
mailx -s "JUNK directory deleted" "email@example.com"