V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
imherer
V2EX  ›  Linux

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

  •  
  •   imherer · 2017-01-13 17:09:55 +08:00 · 2786 次点击
    这是一个创建于 2666 天前的主题,其中的信息可能已经有所发展或是发生改变。
    服务器默认时区是 UTC ,然后改为 KST 之后,发现 crontab 的时区还是 UTC ,应该怎么弄呢, crontab 服务器重启过了也没生效。
    我修改时区的方式是 cp /usr/share/zoneinfo/时区 /etc/localtime
    5 条回复    2017-01-14 00:11:51 +08:00
    imnpc
        1
    imnpc  
       2017-01-13 17:24:11 +08:00
    yum install -y ntpdate
    ntpdate -u pool.ntp.org
    date
    同步下时间试试
    imherer
        2
    imherer  
    OP
       2017-01-13 17:25:46 +08:00
    @imnpc 谢谢。时间已经同步了, crontab 时间不对。刚才重启了 rsyslog 服务,发现其实我重启 crontab 服务之后已经生效了,只是日志时间不对。重启了下 rsyslog 服务,好像现在对了
    wsy2220
        3
    wsy2220  
       2017-01-13 17:26:25 +08:00
    设置一下 TZ 环境变量吧
    imherer
        4
    imherer  
    OP
       2017-01-13 17:47:42 +08:00   ❤️ 1
    @wsy2220 找到问题了,其实重启 crontab 服务就生效了,只是我一直在看 cron 的执行 log ,发现时间不对,重启下 rsyslog 服务, log 里的时间就对了
    julyclyde
        5
    julyclyde  
       2017-01-14 00:11:51 +08:00
    这个问题 tooold 了

    cron 服务重启过是肯定生效滴
    crond 启动瞬间读取“一次” timezone 设置,然后在整个运行过程中不再读
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2298 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 03:32 · PVG 11:32 · LAX 20:32 · JFK 23:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.