Wednesday 14 November 2018

linux - How can I view results of my cron jobs?


I see so many guides on how to run crontab, but what I need right now is to learn how to



  1. Find log files about cron jobs

  2. Configure what gets logged



Answer



Check if the programs you run with cron have their own log files. If if they don't but write their output to the standard outputs you can redirect these to files or mail them to you. Inside crontabs standard shell redirection works.


E.g. to redirect the error output of some_job.sh to some_job.err and discarding the standard output (i.e. sending it to /dev/null) add the following redirection to your crontab


 33 3 * * * /path/to/some_job.sh 1> /dev/null 2> /other/path/to/some_job.err

or to mail it to you instead (if mail is available)


 33 3 * * * /path/to/some_job.sh 1> /dev/null 2>&1 | mail -s "cron output" you@example.org

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...