Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron Job Email Subject

Status
Not open for further replies.

WebStuck

Programmer
Apr 12, 2003
79
US
I have the following example cron job set up through cpanel:

/path_to_script/script.cgi

When the cron job finishes running, I get an email with the output from the script. The email's subject line is, "/path_to_script/script.cgi". I was wondering if there was something I could put in the cron job to specify an email subject line.

Thanks!
Ben
 
I didn't put anything in the cron job to tell it to send me an email. It just automatically sends me an email when the cron job is done running.
 
If you don't redirect the output from the program or script being run, cron will email the output to you. I don't know if there's a way to change the subject that cron uses.

You can just redirect the output and maybe mail it yourself with another script.

You can save the output to a log file. This will mean you won't get an email with the output. Change your crontab entry to something like this...
Code:
0 12 * * * /path-to/script.sh > /path-to/script.log 2>&1
You won't get it mailed, but it will be in a log file for you to check.

Hope this helps.
 
Or if you wanted to still get the output mailed, I guess you could do this in your crontab...
Code:
0 12 * * * /path_to_script/script.cgi 2>&1 | mailx -s "Subject" userid@hostname
You may need to add path information in front of the [tt]mailx[/tt].

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top