Sunday, December 25, 2005

cronjob mail script

Because cron jobs automatically send mail if there is standard output, it is absurdly easy to create a crontab script that sends mail (albeit with somewhat ugly Subject header). Just set the MAILTO variable appropriately and have the command write to stdout if mail should be sent.

For example, a script to test if a file has changed: diff file.bak file ; cp file file.bak

One can mail one's mobile phone to be paged with a text message, etc.

No comments :