Cron backup script stops running after a few days
I set up a cron script to do backups at 3AM every night, and it ran fine for a few days, then stopped. Here are the contents of the script:
Code:
#!/bin/sh and the line in crontab -e that I put in: Code:
0 3 * * * /root/bkup.sh |
Are there any errors in /var/log/cron? Can you see cron attempting to run the script - i.e. has cron died or is there a problem with the script.
Try changing your cron entry so errors are logged:- Code:
0 3 * * * /root/bkup.sh > /root/bkup.log 2>&1 |
You can also look at the mail of the owner of the crontab (that one accessed by the mail command) since the standard error and standard output of cron jobs are redirected there by default (if not explicitly redirected to a file as suggested by blacky_5251).
Edit: uh... sorry, I didn't notice blacky_5251 has already suggested. |
Be sure to redirect any output created by the script to somewhere. That is, if you run the script in the console, and you see any output, it should be redirected to either a log file or to /dev/null.
I don't know exactly why, but if you produce output (either to stdout or stderr) and it is going nowhere while you run a job in background it stops after certain time. jlinkels |
file tar.bz2 is generated?
|
Quote:
It appears the problem was in that I didn't redirect the output of the file to anywhere. After redirecting to /dev/null it appears to be running again. Strange. |
All times are GMT -5. The time now is 08:51 PM. |