need help setting crontab
this is the output of cat /etc/crontab
Quote:
|
If the logs show the scripts being run, but no output is produced, the problem is probably inside the scripts themselves.
Do you use the full path to commands? For example, /usr/bin/tar instead of tar? cron runs with a different environment to a logged in user, paths and environment variables may not be what the script needs. |
No, I just had tar without any path, I changed it now to see if it works. Thanks.
|
I didn't work, I found another thread talking about the same problem and the guys says that he restarted cron and now it works. I will try it to, do you know anything about that?
|
If you're referring to http://www.linuxquestions.org/questi...d.php?t=479234,
then your problem is different from the other one. Your cron jobs work just fine and just don't do what they're expected to. The other post is about cron not detecting any changes to the crontab settings, without restarting cron service. As for your problem, start off by catching any output of your backup script into a file, by modifying the crontab command like this: (/backup/backup_a 2>&1) > /tmp/backup_a.out and likewise for the other ones. If all goes well, you should get at least some clues of what's going wrong (ie error messages in /tmp/backup_a.out). Most likely, they're related to issues with environment variables like $PATH, similar to the issue with tar. |
I tried and then restarted cron to make sure it runs. I tried several times is like the cron weren't reading the file, It did not create any files nor in the backup folder or in tmp/ even thou the log says the script was executed. Any ideas what this could be? thank you again.
|
So the script executes but doesn't seem to do anything? Try putting a simple command like "date" or "whoami" at the top. If you then catch stdout in a file (ie in /tmp), you should see at least the output of that command, just to confirm that the script runs fine.
If it does run fine, then the lack of output may be simply due to the executed commands. |
5 2 * * * root root (/backup/backup_a 2>&1) >/tmp/a.cron.out
6 2 * * * root root (/backup/backup_b 2>&1) > /tmp/b.cron.out 7 2 * * * root root (/backup/backup_c 2<&1) > /tmp/c.cron.out 8 2 * * * root root (/backup/backup_d 2>&1) > /tmp/d.cron.out 40 8 * * * root root /bin/date > /tmp/date.cron.out Thats my crontab, it executed the last command and created the file date.cron.out but it was empty, no data inside the file. I also tried it with the 2>&1 in that case no file was created at all. This is starting to piss me off cause I have no clue. |
I don't really know cron that good, I fixed it using crontab -e and creating the crontab for root and putting the commands there instead of using the file /etc/crontab, for some reason now it works. Thanks anyways for all your help.
|
You're welcome. Glad it works now.
|
All times are GMT -5. The time now is 08:16 AM. |