Wednesday, October 17, 2012

Crontab Log: How to Log the Output of My Cron Script

http://www.thegeekstuff.com/2012/07/crontab-log/

$ crontab -e
59 23 * * * /home/john/bin/backup.sh > /home/john/logs/backup.log 2>&1

In the above:
  • > /home/john/logs/backup.log indicates that the standard output of the backup.sh script will be redirected to the backup.log file.
  • 2>&1 indicates that the standard error (2>) is redirected to the same file descriptor that is pointed by standard output (&1).
  • So, both standard output and error will be redirected to /home/john/logs/backup.log

No comments:

Post a Comment

Popular Posts