Linux – How to change the time cron.daily is run in linux

cronlinuxredhat

I have a script in cron.daily that runs at a certain time every morning. I need to change the time that it is run.

How do I change the time cron.daily runs the scripts?

Best Answer

On Red Hat 5 or older , this is controlled in /etc/crontab.

Newer versions use /etc/anacrontab. By default, cron.daily scripts are run at 4:02. Editing /etc/crontab will modify that time.

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

On Debian/Ubuntu systems, this is controlled in /etc/crontab as well.

For example; a default Ubuntu 12.04 installation:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

And in either case, you may find more details about what syntax to use here: http://linux.die.net/man/5/crontab or by running man 5 crontab on almost any Linux system.