we have a developer who setup a crondoc.txt file that is handling our cron jobs and I am not experienced in cron jobs to know how to understand fully how to change this. I have to do this right away so I am looking for some help. I need to change this so that it emails me and send the cron job to a file.
0,20,40 8,9,10,11,12,13,14,15,16,17,18,19,20 * * 1,2,3,5,6,7 /usr/bin/php /home/folder/filename.php >> /dev/null 2>&1
UPDATE: This is actually what does not make sense to me. There is one crontab above and then there is another setup like this below:
0 2 * * 5 /usr/bin/php /home/folder/filename.php | mail -s "Service Alert Output" me@myemail.com
Question: How do I combine them so I can get the email and also log to a file?
I don’t know what the ending means after the file name starting at >> but would like this to email me and put into a log file. Possible? Example would be great to help me get this accomplished.
Thank you.
Rob
To change email settings, you should use MAILTO variable, for example put
MAILTO=vivek@nixcraft.in
at the beginning of cron file. You can read more about MAILTO variable here – http://www.cyberciti.biz/faq/linux-unix-crontab-change-mailto-settings/
With regards to >> /dev/null 2>&1 part, it redirects output of the command to /dev/null file. So you should change /dev/null to the filename where you want to save output of the command.
EDIT:
Example of full crontab file:
I think you don’t need to pipe output of the command to mail program because crontab has builtin feature for it.