Last active
June 23, 2016 06:08
-
-
Save nguyenthanhtung88/59207715df3b0b644f1864b7d9273a34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Setup crontab | |
``` | |
$ crontab -e | |
59 23 * * * /home/john/bin/backup.sh | |
``` | |
2. View log running | |
``` | |
$ tail /var/log/cron | |
Oct 8 22:00:00 dev-db crond[18340]: (root) CMD (/bin/sh /home/root/bin/system_check &) | |
Oct 8 23:00:00 dev-db crond[20348]: (oracle) CMD (/bin/sh /home/oracle/bin/cleanup.sh &) | |
Oct 8 23:59:00 dev-db crond[20399]: (john) CMD (/bin/sh /home/john/bin/backup.sh &) | |
``` | |
3. Debug log error | |
``` | |
$ crontab -e | |
59 23 * * * /home/john/bin/backup.sh > /home/john/logs/backup.log 2>&1 | |
``` | |
Note: | |
- > /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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment