Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move cron.daily to run earlier #1

Open
inghamn opened this issue Feb 1, 2017 · 1 comment
Open

Move cron.daily to run earlier #1

inghamn opened this issue Feb 1, 2017 · 1 comment

Comments

@inghamn
Copy link
Member

inghamn commented Feb 1, 2017

Ubuntu's default configuration sets cron.daily stuff to start running at 6:00 am. Unattended upgrades are part of that, and occur fairly late in the process. By the time Unattended Upgrades run and reboot, it's usually 8:00 am. This is putting upgrades and reboots into normal working hours.

We should adjust crontab to start the cron.daily stuff earlier.

I know Ubuntu is usuing Anacron, so we'll need to make sure we understand how to control when things run.

@pgporada
Copy link
Contributor

pgporada commented Mar 14, 2017

On Ubuntu 16.04, /etc/cron.daily will run at 06:25AM.

$ cat /etc/crontab 
# /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 )

Since Ubuntu is using anacron, the job will be kicked off once 1 per day, but staggered by 5 minutes.

$ cat /etc/anacrontab 
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
HOME=/root
LOGNAME=root

# These replace cron's entries
1	5	cron.daily	run-parts --report /etc/cron.daily
7	10	cron.weekly	run-parts --report /etc/cron.weekly
@monthly	15	cron.monthly	run-parts --report /etc/cron.monthly

You may want to template the /etc/cron.daily file to run earlier so that your unattended upgrades finish before 8AM. Just a suggestion at least. Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants