How to Modify a Cronjob Email Subject
Solution 1:
Or use the sh noop command (:)
0 9-17 * * 1-5 : Queue Summary; PATH=/usr/sbin qshape
The subject still looks kludgey, but at least it's descriptive and requires no extraneous scripts.
Solution 2:
Pipe your cron job output to mail directly, and then you can fill in the subject line. the 2>&1
syntax sends any error output which would otherwise disappear.
mycmd 2>&1 | mail -s "mycmd output" myname
Solution 3:
Take over crond's responsibility for sending command output (or not if there isn't any) by piping output and stderr into 'mailx -E'. For example:
0 * * * * your-command 2>&1 | mailx -E -s "Descriptive Subject" $LOGNAME
Mailx's '-E' option is nice because, just like crond itself, it won't send a mail if there isn't any output to send.
Solution 4:
On my systems (most Debian) all output, from a script/program called as a crontab-entry, is sent by email to the account@localhost
who initiated the cron.
These emails have a subject like yours.
If you want to receive an email, write a script that has no output on its own. But instead put all output in a textfile.
And with
mail -s 'your subject' adress@where < textfile
you receive it the way you want.
Solution 5:
Another solution is to write a shell script with the subject line you want that calls the right command. In your example, this would be:
#Optimize_MySQL_Database.sh
/ramdisk/bin/php5 -c /home5/username/scheduled/optimize_mysql.bash
You can include your bin directory in the path by setting it in the crontab file.