Restarting cron after changing crontab file?

后端 未结 11 1500
刺人心
刺人心 2020-11-30 16:38

Do I have to restart cron after changing the crontable file?

相关标签:
11条回答
  • 2020-11-30 17:09

    Depending on distribution, using "cron reload" might do nothing. To paste a snippet out of init.d/cron (debian squeeze):

    reload|force-reload) log_daemon_msg "Reloading configuration files for periodic command scheduler" "cron"
        # cron reloads automatically
        log_end_msg 0
        ;;
    

    Some developer/maintainer relied on it reloading, but doesn't, and in this case there's not a way to force reload. I'm generating my crontab files as part of a deploy, and unless somehow the length of the file changes, the changes are not reloaded.

    0 讨论(0)
  • 2020-11-30 17:09

    Ubuntu 18.04 * Usage: /etc/init.d/cron {start|stop|status|restart|reload|force-reload}

    0 讨论(0)
  • 2020-11-30 17:10

    On CentOS (my version is 6.5) when editing crontab you must close the editor to reflect your changes in CRON.

    crontab -e
    

    After that command You can see that new entry appears in /var/log/cron

    Sep 24 10:44:26 ***** crontab[17216]: (*****) BEGIN EDIT (*****)
    

    But only saving crontab editor after making some changes does not work. You must leave the editor to reflect changes in cron. After exiting new entry appears in the log:

    Sep 24 10:47:58 ***** crontab[17216]: (*****) END EDIT (*****)
    

    From this point changes you made are visible to CRON.

    0 讨论(0)
  • 2020-11-30 17:21

    There are instances wherein cron needs to be restarted in order for the start up script to work. There's nothing wrong in restarting the cron.

    sudo service cron restart

    0 讨论(0)
  • 2020-11-30 17:23

    1) If file /var/spool/cron/crontabs/root edit via SFTP client - need service cron restart. Reload service not work.

    2) If edit file /var/spool/cron/crontabs/root via console linux (nano, mc) - restart NOT need.

    3) If edit cron via crontab -e - restart NOT need.

    0 讨论(0)
提交回复
热议问题