Cron Job Output to mail

I was looking for a output of Cron Job, whenever it runs. The output can be a general output of script or any error generated by script.

There's standard output (STDOUT) and standard errors (STDERR). STDOUT is marked 1, STDERR is marked 2. So the following statement tells Linux to store STDERR in STDOUT as well, creating one datastream for messages & errors:


2>&1

Lets say if you want to send cron output to mail then edit below entry in crontab.


13 15 * * * /root/my.sh 2>&1 | mail -s "Cronjob ouput" alpesh.bhavsar@yahoo.c0m


No comments:

Post a Comment