0

I added a job for backup to my cron jobs, using crontab -e:

0 0 * * * tar -czf /somewhere/backup.tar.gz --exclude='sth/backup' --directory='/var/www' sth

But when I check the created file, with stat, it shows this:

Access: 2015-08-26 11:55:48.000667280 +0430
Modify: 2015-09-03 08:30:07.946818661 +0430
Change: 2015-09-03 08:30:07.946818661 +0430

As you see, the modification time of the file is 08:30. But in the crontab, I have set this to execute on 00:00 (12 at midnight).

Why is this happening?

14
  • Perhaps it took 8.5 hours to complete?
    – bskool
    Sep 3, 2015 at 8:20
  • Oh, no! It takes about 4 or 5 seconds only.
    – Ahmad
    Sep 3, 2015 at 8:21
  • What is the output of crontab -u USER -l
    – bskool
    Sep 3, 2015 at 8:24
  • A lot of comments, followed by my commands, including the one that is in the question.
    – Ahmad
    Sep 3, 2015 at 8:27
  • 1
    I'd guess that this is because of time zone confusion. The output from stat suggests that your shell is operating in UTC+0430 (Afghanistan?). Sounds like cron is running in a different time zone. Looking at /var/log/cron might clarify this. Sep 3, 2015 at 9:00

1 Answer 1

0

The problem was originating from that I had changed the server's timezone a long time ago, but because I did not restart my server for several months, the changes did not apply to the cron service.

The main point is you have to restart the cron service after changing the timezone in order to take effect.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .