I have set several cron jobs. I recently added a new cron job that copies a file of last day from another server and is executed each day (for example at 06:00 am) but when I check next day the file hasn't been copied.
When I arrrive office and realize that job wasn't executed, then I edit the job with crontab -e (with same root user) and set the job to be executed in next 30 min. This time the cron job is executed successfully.
Why could be that the job is not being executed at 04:00 or 06:00 am but during day it works?
How can I check the reason why the job is not executed?
I'm working in GNU/Linux CentOS (2.6.32) system. Thanks for any help.
The files that I need to copy are created in the origin server before 23:00 hours.
I had the cron job like this: (The first line is the job that fails. related script to copy the files is
[root@srvc ~]# crontab -l 0 6 * * * /path/to/scripts/script1.sh 0 5 * * * /path/to/scripts/script3.sh 0 8 * * 1 /path/to/scripts/script4.sh
When I checked today about 11:00 am that file wasn't copied, I edited cron job to be executed at 11:10 am and the file was copied successfully.
[root@srvc ~]# crontab -l 10 11 * * * /path/to/scripts/script1.sh
script1.sh content is this:
#!/bin/bash dyear=`date +'%Y' -d "1 day ago"` dmonth=`date +'%b' -d "1 day ago"` ddate=`date +%Y-%m-%d -d "1 day ago"` sshpass -p 'ThePassword' scp -r root@X.X.X.X:/path/to/files/*$ddate* /Destination/path/$dyear/$dmonth/
The files to be copied have in their name the format