简体   繁体   中英

Crontab executes at the wrong time

I have a crontab settings as follows:

sudo crontab -l -u bheng

Contents:

#field          allowed values
#          -----          --------------
#          minute         0-59
#          hour           0-23
#          day of month   1-31
#          month          1-12 (or names, see below)
#          day of week    0-7 (0 or 7 is Sun, or use names)
#

# m h  dom mon dow   command
MAILTO="bheng@outlook.com"

#Daily 
01 22 * * * php /home/mysite.com/artisan products:exportdiff --interval="yesterday"
16 22 * * * php /home/mysite.com/artisan images:exportdiff --interval="yesterday"
31 22 * * * php /home/mysite.com/artisan publications:exportdiff  --interval="yesterday"

#Weekly
1  23 * * 7 php /home/mysite.com/artisan publications:exportdiff --interval="last sunday"
16 23 * * 7 php /home/mysite.com/artisan images:exportdiff --interval="last sunday"
31 23 * * 7 php /home/mysite.com/artisan products:exportdiff --interval="last sunday"

As you can see, it suppose to be kicking at 10 and 11 PM at night.

But instead, I got 3 emails at 5 PM yesterday at 5:01 PM, 5:16 PM, 5:31 PM.

I thought it was the time wrong the in system or VM so I checked it I saw UTC time.

Then, I update it by running sudo dpkg-reconfigure tzdata and set it to US Eastern time.

Now, when I ran date command I got Ex.Thu Dec 15 07:56:27 EST 2016 correctly as US EST time.

Is there some service that I need to restart?

Or is this something other crontab settings that might have overwrite my current settings ?

I believe you have to restart cron after making time / time zone related changes.

Depending on your version of cron, you might be able to restart it with sudo service cron restart .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM