Linux cron 的执行时间问题

服务器上需要在每天0点定时执行脚本

1
2
3
#cronjob -e
MAILTO="xxx@xxx.xxx"
0 0 * * * /usr/local/bin/php /home/xxx/aaa.php >> aaa.log


但总是不在指定的时间执行,看了下 cron 的日志

1
2
3
4
5
#cat /var/log/cron|grep 'aaa.php'
Feb 16 13:00:01 host crond[3407]: (alex) CMD (/usr/local/bin/php /home/xxx/aaa.php >> aaa.log)
Feb 17 13:00:01 host crond[20456]: (alex) CMD (/usr/local/bin/php /home/xxx/aaa.php >> aaa.log)
Feb 18 13:00:01 host crond[25732]: (alex) CMD (/usr/local/bin/php /home/xxx/aaa.php >> aaa.log)
Feb 19 13:00:01 host crond[10169]: (alex) CMD (/usr/local/bin/php /home/xxx/aaa.php >> aaa.log)

可以看到是每天的13点执行,这个时间与本地时间正好13个小时。
服务器在美国,按说差13个小时也是正常,但在服务器上执行date命令却和+8区时间一样。
查了点资料,据说是修改服务器时区后没有重新启动 cron 服务或者重启服务器。
不过既然知道是晚了13个小时改改cronjob就行了,服务器上还跑的有别的程序,重启怕出问题

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
This entry was posted in Technologies and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>