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

定时重启不起作用,哪里的问题?(cron 相关)

  •  
  •   cathedrel · Aug 27, 2021 · 2903 views
    This topic created in 1714 days ago, the information mentioned may be changed or developed.

    通过 webmin 设置了每周四半夜重启 VPS,前几天设置的,到现在应该有重启一遍了,但是,现在看系统的运行时间还是 3 天多,这是第一次用 cron 相关的东西,百思不得其解,请大佬们拿捏一下是哪里的问题:

    webmin 的设置:i.imgur.com/Yhi6c4B.png

    终端看:i.imgur.com/KJYGbRK.png

    Supplement 1  ·  Aug 27, 2021
    确实是路径问题,用"/sbin/reboot"就 OK 了
    10 replies    2021-08-27 15:31:40 +08:00
    Foxkeh
        1
    Foxkeh  
       Aug 27, 2021   ❤️ 1
    猜测是程序路径不完整, 不知你这边是什么系统, 我这边看 CentOS7 是在 /usr/sbin/reboot
    bruce0
        2
    bruce0  
       Aug 27, 2021   ❤️ 1
    盲猜是路径的问题, 可以通过 /var/mail/ 目录下 对应账户的 邮件看到报错信息

    比如看 root 用户的

    cat /var/mail/root 就能看到 crontab 的错误信息了
    superrichman
        3
    superrichman  
       Aug 27, 2021   ❤️ 1
    cron 的执行环境的环境变量的比用户的少很多,它找不到 reboot 在哪,你要用完整的路径
    AllenHua
        4
    AllenHua  
       Aug 27, 2021   ❤️ 1
    crontab 、systemctl 等程序里要用完整的可执行文件路径。你直接使用 reboot,看 cron 日志(话说我也没看过 cron 的执行日志)有可能会有 'reboot' command not found 的日志
    doveyoung
        5
    doveyoung  
       Aug 27, 2021   ❤️ 1
    盲猜路径问题 +1
    crontab 里头写完整路径
    yEhwG10ZJa83067x
        6
    yEhwG10ZJa83067x  
       Aug 27, 2021
    不是应该先执行一遍,看看能不能执行啊。这个排除后再来排查其他吧
    cathedrel
        7
    cathedrel  
    OP
       Aug 27, 2021 via Android
    @justrand 没有执行是以为它这个执行也是到点才执行……
    yEhwG10ZJa83067x
        8
    yEhwG10ZJa83067x  
       Aug 27, 2021
    @cathedrel 所以到点不执行就可以去执行一下是不是本身就无法执行,大概率是这个问题
    tankren
        9
    tankren  
       Aug 27, 2021
    最优是写一个 shell 然后定时执行 还可以做做备份 写写 log
    eason1874
        10
    eason1874  
       Aug 27, 2021
    我也遇过这个坑,sh 嵌套 sh,手动执行没问题,自动就提示没找到程序,后来才意识到没引入环境变量
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5383 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 09:26 · PVG 17:26 · LAX 02:26 · JFK 05:26
    ♥ Do have faith in what you're doing.