Restarting cron after changing crontab file?

LinuxUnixCronCron Task

Linux Problem Overview


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

Linux Solutions


Solution 1 - Linux

No.

From the cron man page:

> ...cron will then examine the modification time on all crontabs > and reload those which have changed. Thus cron need not be restarted > whenever a crontab file is modified

But if you just want to make sure its done anyway,

sudo service cron reload

or

/etc/init.d/cron reload

Solution 2 - Linux

On CentOS with cPanel sudo /etc/init.d/crond reload does the trick.

On CentOS7: sudo systemctl start crond.service

Solution 3 - Linux

I had a similar issue on 16.04 VPS Digital Ocean. If you are changing crontabs, make sure to run

sudo service cron restart 

Solution 4 - Linux

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.

Solution 5 - Linux

Commands for RHEL/Fedora/CentOS/Scientific Linux user

  1. Start cron service

    • To start the cron service, use: /etc/init.d/crond start

    • OR RHEL/CentOS 5.x/6.x user: service crond start

    • OR RHEL/Centos Linux 7.x user: systemctl start crond.service

  2. Stop cron service

    • To stop the cron service, use: /etc/init.d/crond stop

    • OR RHEL/CentOS 5.x/6.x user: service crond stop

    • OR RHEL/Centos Linux 7.x user: systemctl stop crond.service

  3. Restart cron service

    • To restart the cron service, use: /etc/init.d/crond restart

    • OR RHEL/CentOS 5.x/6.x user: service crond restart

    • OR RHEL/Centos Linux 7.x user: systemctl restart crond.service

Commands for Ubuntu/Mint/Debian based Linux distro

  1. Debian Start cron service

    • To start the cron service, use: /etc/init.d/cron start

    • OR sudo /etc/init.d/cron start

    • OR sudo service cron start

  2. Debian Stop cron service

    • To stop the cron service, use: /etc/init.d/cron stop

    • OR sudo /etc/init.d/cron stop

    • OR sudo service cron stop

  3. Debian Restart cron service

    • To restart the cron service, use: /etc/init.d/cron restart

    • OR sudo /etc/init.d/cron restart

    • OR sudo service cron restart

Source: https://www.cyberciti.biz/faq/howto-linux-unix-start-restart-cron/

Solution 6 - Linux

try this one for centos 7 : service crond reload

Solution 7 - Linux

Try this out: sudo cron reload It works for me on ubuntu 12.10

Solution 8 - Linux

  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.

Solution 9 - Linux

Try this: service crond restart, Hence it's crond not cron.

Solution 10 - Linux

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

Solution 11 - Linux

Ubuntu 18.04

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

Solution 12 - Linux

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionbArmageddonView Question on Stackoverflow
Solution 1 - LinuxleonbloyView Answer on Stackoverflow
Solution 2 - LinuxSheldmanduView Answer on Stackoverflow
Solution 3 - LinuxGyroView Answer on Stackoverflow
Solution 4 - LinuxTit PetricView Answer on Stackoverflow
Solution 5 - LinuxMahdi BashirpourView Answer on Stackoverflow
Solution 6 - LinuxFlairView Answer on Stackoverflow
Solution 7 - LinuxjonoView Answer on Stackoverflow
Solution 8 - LinuxvebmasterView Answer on Stackoverflow
Solution 9 - LinuxakoView Answer on Stackoverflow
Solution 10 - LinuxMawtyView Answer on Stackoverflow
Solution 11 - LinuxAqua HuangView Answer on Stackoverflow
Solution 12 - LinuxWojciech WirzbickiView Answer on Stackoverflow