Do I need to refresh or restart anything after I add/update a crontab in Ubuntu Server 8.04?

106,591

Solution 1

No. As long as you use the crontab -e command to edit the file, when you save it, you'll get a 'New Crontab Installed' message. That's it.

Solution 2

The usual thing is to use crontab -e to edit the tables. The changes will be applied when you exit the editor. Otherwise the rules for re-reading changed crontabs are in the cron(8) man page. They will be re-read eventually, you don't need to do anything.

Solution 3

It's important that you elaborate on HOW/WHERE you are adding crons. But I think the following addresses any situation.

Yes, cron needs to be made aware that you made changes, but no, you don't necessarily need to explicitly do anything to update it.

I'm paraphrasing the cron manual here for the short version:

As mentioned, crontab -e, the preferred method, will notify cron that something changed.

However, cron "wakes up" every minute to see if it has tasks for that minute. It also scans /var/spool/cron/crontabs and will reload any files with an updated 'mtime' (modified time, meaning the file contents must have been updated).

So theoretically, if you do nothing, cron will "wake up" and see you made changes to anything directly in /var/spool/cron/crontabs.

But if you can, use crontab -e. When you are done editing, it even gives you feedback that it was updated, it says:

    crontab: installing new crontab

Specifically, this means that it refreshed its copy in memory for the file you just edited via crontab.

Here's a quote from the manual CRON(8) :

    cron searches its spool area (/var/spool/cron/crontabs) for
    crontab files (which are named after accounts in /etc/passwd);
    crontabs found are loaded into memory.  Note that crontabs in this
    directory should not be accessed directly - the crontab command
    should be used to access and update them.
Share:
106,591

Related videos on Youtube

RayJamesFun
Author by

RayJamesFun

Updated on September 18, 2022

Comments

  • RayJamesFun
    RayJamesFun over 1 year

    When you change something in Apache you need to reload or restart apache. Does anything need to be refreshed or restarted in Ubuntu Server 8.04 after I add/update the crontab? Thanks a bunch for your help.

  • Keith Thompson
    Keith Thompson over 12 years
    The same applies to crontab <filename> -- and to crontab -r, for that matter.
  • user5359531
    user5359531 almost 7 years
    But what if you did not use crontab -e to edit the file?
  • Safado
    Safado almost 7 years
    It should still work if you edited the file directly, assuming you had permissions to do so. It's still recommended to use the crontab command.
  • JoLoCo
    JoLoCo almost 7 years
    @user5359531 If you want to restart cron for whatever reason (which will force reloading of crontab files) see this SO question: stackoverflow.com/questions/10193788/…