V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
imherer
V2EX  ›  Linux

Linux 时区更改后 crontab 任务时间不对

  •  
  •   imherer · Jan 13, 2017 · 3276 views
    This topic created in 3398 days ago, the information mentioned may be changed or developed.
    服务器默认时区是 UTC ,然后改为 KST 之后,发现 crontab 的时区还是 UTC ,应该怎么弄呢, crontab 服务器重启过了也没生效。
    我修改时区的方式是 cp /usr/share/zoneinfo/时区 /etc/localtime
    5 replies    2017-01-14 00:11:51 +08:00
    imnpc
        1
    imnpc  
       Jan 13, 2017
    yum install -y ntpdate
    ntpdate -u pool.ntp.org
    date
    同步下时间试试
    imherer
        2
    imherer  
    OP
       Jan 13, 2017
    @imnpc 谢谢。时间已经同步了, crontab 时间不对。刚才重启了 rsyslog 服务,发现其实我重启 crontab 服务之后已经生效了,只是日志时间不对。重启了下 rsyslog 服务,好像现在对了
    wsy2220
        3
    wsy2220  
       Jan 13, 2017
    设置一下 TZ 环境变量吧
    imherer
        4
    imherer  
    OP
       Jan 13, 2017   ❤️ 1
    @wsy2220 找到问题了,其实重启 crontab 服务就生效了,只是我一直在看 cron 的执行 log ,发现时间不对,重启下 rsyslog 服务, log 里的时间就对了
    julyclyde
        5
    julyclyde  
       Jan 14, 2017
    这个问题 tooold 了

    cron 服务重启过是肯定生效滴
    crond 启动瞬间读取“一次” timezone 设置,然后在整个运行过程中不再读
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2899 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 70ms · UTC 07:16 · PVG 15:16 · LAX 00:16 · JFK 03:16
    ♥ Do have faith in what you're doing.