Cron – How to Modify a Cronjob Email Subject

cronemail

I am running a half dozen different cron jobs from my hosting at Hostmonster.com. When a cronjob has been executed I receive an email with the output of the script.

The email comes in the format of:

From: Cron Daemon
Subject: Cron  /ramdisk/bin/php5 -c /home5/username/scheduled/optimize_mysql.bash

The problem with this is that the subject of the email makes it very hard to read which cronjob the email is pertaining to.

Is there a way to modify the subject of a cronjob email so that it's easier to read?

For example:

From: Cron Daemon
Subject: Optimize MySQL Database

Best Answer

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.