572

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

Mohit Rathod
  • 1,057
  • 1
  • 19
  • 33
bArmageddon
  • 8,088
  • 6
  • 22
  • 40
  • 11
    Not to disregard @leonbloy's answer, but I found that implementing my linux's first cron job (a correctly formatted per minute job) didn't action until the system was rebooted. `sudo service cron restart` wasn't tested. – geotheory Jul 02 '14 at 09:56
  • 4
    @geotheory yikes I sure hope I don't have to restart my prod server any time I update my crontab (and I don't). – jcollum Nov 08 '16 at 20:46

12 Answers12

807

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
Ani Menon
  • 27,209
  • 16
  • 105
  • 126
leonbloy
  • 73,180
  • 20
  • 142
  • 190
  • 13
    If using cron.d folder, symlinked crontabs will not be reloaded. How can I force a reload? – CMCDragonkai Jan 10 '14 at 18:00
  • 2
    @CMCDragonkai `/etc/init.d/cron restart` ? – leonbloy Jan 10 '14 at 18:12
  • 16
    Ah it's that easy. It's now `sudo service cron restart`. – CMCDragonkai Jan 10 '14 at 18:25
  • 22
    Better option is reload - it can be initiated by non-root user: ```/etc/init.d/cron reload``` – Honza May 06 '14 at 04:50
  • 15
    @CMCDragonkai Possibly `crond` instead of `cron`. – Cees Timmerman Jul 21 '15 at 12:48
  • 58
    The only problem with this answer is that it's not always true. See geotheory's comment underneath the question. I, too, was bit by this. I made a change to the crontab file via `sudo crontab -e`, saved the change by `Ctrl + X`, and went away assuming `cron` would pick it up (due to this answer being so highly upvoted). Then, days later my client reports that the cron is still running on the old cycle. So - honestly - if you want to be safe - just restart either `cron` or the system, and don't play around with wasted time testing, which you'll have to do despite this highly-upvoted answer. – Dan Nissenbaum Oct 14 '15 at 22:53
  • sudo service crond reload works for me to reload de cron definition files on /etc/crontab – ChoCho Mar 28 '18 at 20:26
  • On FreeBSD and OpenBSD you need to restart the cron service after create a file under /var/cron/tabs/user or /var/cron/tabs/user – rfmoz Aug 15 '18 at 09:12
  • 1
    On my Raspberry Pi 3+ with Ubuntu 18.04.2 LTS the only command that worked for me was: `sudo service cron reload`. It was also the only command which gave a response: `* Reloading configuration files for periodic command scheduler cron`. – Jan Apr 19 '19 at 08:44
  • I guess this is distribution-specific. On Ubuntu 20.04, with default (Vixie) cron, plain edits (with `vim`, not `crontab`) to a user-specific crontab (`/var/spool/cron/crontabs/user-foo`) *are* picked up and acted on immediately; tested with a per-minute echo and `tail`ing the user's mail file. This is also true if you simply copy in the user's cron file during installation. – EML Jan 30 '22 at 17:48
75

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

On CentOS7: sudo systemctl start crond.service

jcollum
  • 43,623
  • 55
  • 191
  • 321
Sheldmandu
  • 1,700
  • 16
  • 10
  • 5
    Thanks for the CentOs 7 line – Mathieu de Lorimier Dec 15 '17 at 02:50
  • 4
    // , To reload `crond`, rather than just start it on the increasingly horrible systemd, run `sudo systemctl reload crond.service`. – Nathan Basanese Oct 03 '18 at 18:26
  • 1
    @NathanBasanese Reloading `cron` on SystemD now is considered black magic: `sudo systemctl reload crond` fails with `Failed to reload cron.service: Job type reload is not applicable for unit cron.service.` (Ubuntu 18.04). Read: Heads off, we all are pwned by the syndrome: "SystemD, there can be only one". If reload is not done automagically behind the scenes, you are bust! Do not even think about fixing it, like you did for the last 3 (or more) decades! Read: **The world of Windows has finally swallowed Debian: If there's something strange under the hood, what you gonna do? Restart!** – Tino Jan 16 '19 at 19:55
  • Restart is more than just reload. Isn't there a clean reload option available for Centos? – Ωmega Apr 18 '19 at 19:46
  • @Tino you can install cronie – Bob Jun 19 '19 at 11:30
45

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

sudo service cron restart 
Niclas
  • 61
  • 8
Gyro
  • 733
  • 7
  • 11
20

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/

Mahdi Bashirpour
  • 17,147
  • 12
  • 117
  • 144
  • 2
    This does not appear to attempt to answer the question at the top of this page at all. Please review the [help] and in particular [How do I write a good answer?](/help/how-to-answer) – tripleee Mar 30 '21 at 06:02
17

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.

Tit Petric
  • 315
  • 1
  • 3
  • 8
12

try this one for centos 7 : service crond reload

Flair
  • 169
  • 1
  • 5
10
  1. If file /var/spool/cron/crontabs/root edited via SFTP client - service cron restart needed. Reload service not work.

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

  3. If edited cron via crontab -e - restart NOT needed.

Danijel
  • 8,198
  • 18
  • 69
  • 133
vebmaster
  • 101
  • 1
  • 3
7

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

jono
  • 79
  • 1
  • 1
5

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

ako
  • 2,000
  • 2
  • 28
  • 34
3

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

Mawty
  • 428
  • 3
  • 10
3

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.

Wojciech Wirzbicki
  • 3,887
  • 6
  • 36
  • 59
2

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

Aqua Huang
  • 129
  • 1
  • 1