Need to schedule updates and installs

Asked by Bruce Bon

My ISP is HughesNet satellite, which severely penalizes overstepping my downlink quota except between the hours of 2 am and 7 am. I have a new Ubuntu Jaunty system, with over 130 MB of updates alone, plus a number of large installs I need to do. It appears that I cannot use the either Add/Remove Applications or the Synaptic Package Manager to schedule such activity, and the Advanced Package Management section (which covered apt-get) has been removed from the Adding, Removing and Updating Applications between Intrepid and Jaunty.

So what is now the accepted, best-practice way of doing my installs and updates at 2 am, other than staying up for the graveyard shift?

If the answer is simply to use apt-get and cron, I can figure out how to do that, but I'm a little confused about (1) why no one has seen fit to include a scheduling option in the Synaptic Package Manager and (2) why the powers that be removed apt-get documentation from the manual -- does it mean that one should avoid using apt-get under Jaunty?

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu synaptic Edit question
Assignee:
No assignee Edit question
Solved by:
Bruce Bon
Solved:
Last query:
Last reply:
Revision history for this message
Michael Fletcher (mikefletcher) said :
#1

What I can give you is some information on how it is implemented right now. When you choose "Daily" from the System -> Administration -> Update Manager -> Settings (button) it adds an apt based upgrade to the "daily" cron jobs. Cron automatically runs all the jobs in /etc/cron.daily/ at 6:25 am in your local timezone. The apt update adds a random delay so that all workstations do not hit the update servers at exactly the same time. If your interested the files are /etc/crontab and /etc/cron.daily/apt.

As for how to fix the problem ... I suggest you edit /etc/crontab and change when cron.daily happens to 2:00 am. I think that is the smallest change you can make.

I have no idea why it was removed. This is a community answer service.

Apt-get in fundamental to the workings of Ubuntu. Its not going away any time soon. Documentation is available from the terminal if you type 'man apt-get'. I have no idea why it would have been removed.

Revision history for this message
Michael Fletcher (mikefletcher) said :
#2

This is an example of what a crontab that ran at 2:00 am would look like

25 2 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

   ^^^ change the 6 to a 2. Now it runs at 2:25

Revision history for this message
Bruce Bon (bbon) said :
#3

Thanks, guys -- that is easy to understand, and I just set it up -- we'll see how it works tonight.

Under the Update Manager settings, I chose "Download all updates in the background." If it had let me, I would have also chosen "Install security updates without confirmation." I assume that download will download but NOT install, and the install will happen when I confirm it later? Or does it really mean "Download and install all updates in the background"?

The other half of the question is, is there an easy way to schedule new application installs? The Add/Remove... window has no Settings button or any other way to schedule. I know how to do crontab stuff if I need to, so I can do apt-get in a cron job, but that is error-prone, at best -- one typo and we try again tomorrow night! Is there a more idiot-proof way?

Thanks.

Revision history for this message
Bruce Bon (bbon) said :
#4

Report on last night -- nothing ran.

My HughesNet activity log showed no download activity between 2 am and 7 am; the /var/log/syslog file showed no cron job running then either; "crontab -l" from root says no crontab is active, but this may be normal -- I notice that /etc/crontab comments say you don't have to run crontab, so this seems to be a separate cron type from what I know about. There is a cron process running, from /usr/sbin/cron.

My /etc/crontab file:

# /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
05 2 * * * 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 )
#

Revision history for this message
Michael Fletcher (mikefletcher) said :
#5

Hi. I did some research and figured out why you are having problems. All of the information I gathered is from this article: http://www.tuxradar.com/content/automate-linux-cron-and-anacron

So basically there are two "cron" daemons on Ubuntu. Cron and anacron. Cron behaves like we talked about before. Anacron is designed to run commands on a schedule (ex daily) but not at a specific time. Anancron is appropriate from most computers that are not turned on 24 hours a day.

In Ubuntu anacron is usually responsible for executing jobs. If you look at the crontab cron only runs the daily jobs if anacron is not installed:

05 2 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

I would suggest fixing this by

1. Removing the 'test' part of the crontab so it looks like follows

05 2 * * * root cd / && run-parts --report /etc/cron.daily

2. Commenting out the daily part of /etc/anacrontab.

#1 5 cron.daily nice run-parts --report /etc/cron.daily
^ put a hash in front of the line

Revision history for this message
Michael Fletcher (mikefletcher) said :
#6

Sorry I missed this question

> The other half of the question is, is there an easy way to schedule new application
> installs? The Add/Remove... window has no Settings button or any other way to
> schedule. I know how to do crontab stuff if I need to, so I can do apt-get in a cron
> job, but that is error-prone, at best -- one typo and we try again tomorrow night! Is
> there a more idiot-proof way?

The best I can suggest is using the -s command of apt-get. That sortof stands for "simulation". Its lets you try out the apt-get command durring the day without actually executing it.

ex:

# apt-get install -s postgresql
# sudo at 03:00
apt-get install postgresql
CTRL-D
#

Revision history for this message
Bruce Bon (bbon) said :
#7

Report on overnight 2009-08-03:

First of all, thanks Michael for all of the information -- I'm learning a lot. But things still aren't working as I would like them.

First problem was that, apparently, choosing "Download all updates in the background" in Update Manager/Settings causes update to run right away, because all my updates were downloaded within the hour after I made that change yesterday. Either that, or anacron caused the daily job to run just then -- I may not have modified the crontab and anacron files in time to stop it.

Second problem was that I could find no evidence that any cron job ran at 2:05 this morning, as specified in the revised crontab. After considerable analysis, I found that I had deleted the username (i.e. "root") from the crontab line in step 1 of your solution, and that caused the cron job not too run. I fixed that, so hopefully it will run OK tonight.

Other relevant findings, possibly useful to others:
   - anacron is run daily at 7:30 am by cron, using a crontab in /etc/cron.d/anacron . This is how it is run after boot time.
   - start and stop messages for anacron, and a few others, appear in /var/log/syslog .

Although I haven't fully tested the solutions Michael provided, I now believe that I have enough information to take it from here, so I'm going to mark this question as Solved. Thanks again for all of the help.