apt-get with cronjob

If none of the more specific forums is the right place to ask

apt-get with cronjob

Postby Rambo » 2004-05-05 17:50

Hi folks!

I was thinking; Since my computer is never turned off, it would very wel be possible to update and upgrade (apt-get) automaticly with cron, right?

I was thinking when I let a cron job do the up-dating/grading every night at 04:00 am (this is the time I normaly spend my time in bed instead of behind my keyboard) I should always have an up-to-date system.

Is this possible? And when it is, are the some special things I should know?

greetz Rambo
Rambo
 
Posts: 9
Joined: 2004-03-19 20:07

Postby lacek » 2004-05-06 10:59

It is possible, however, you should do a few things before you can start:
- Set the debconf utility to use 'noninteractive' frontend, so it won't hold the cron job. You can do it with 'dpkg-reconfigure debconf'. If you ever want to get your old frontend back, you can use the above command with the -f switch. See the man page of dpkg-reconfigure and debconf for details.

- Tell apt-get to assume yes on all questions. This will make apt-get to answer yes on all questions but the ones which may harm your system. In that latter case, apt will bail out, and you'll probably get a mail next morning from cron about the failure.

- Redirect the output of the commands to /dev/null, so cron will not spam you with mails, but if an error occurs, you'll get a mail. It may sound obvious, but I forgot it many times... :-)
However, if you want to see the output of the commands to track which packages upgraded, ignore this third point.

So, the final line in your crontab should be something like that:
0 4 * * * root (apt-get update && apt-get -y upgrade) >/dev/null

It is just a lame example, but it should do. You may want to write a more complex command here...
lacek
Moderator Team Member
 
Posts: 769
Joined: 2004-03-11 18:49
Location: Budapest, Hungary

Postby Rambo » 2004-05-06 16:32

Thanks.

I"m glad I asked!
Rambo
 
Posts: 9
Joined: 2004-03-19 20:07

Postby Guest » 2004-05-07 05:05

Is there somewere on howto on this topic?
Guest
 

Postby Guest » 2004-05-09 14:37

I'd rather avoid doing a system upgrade automatically.
Too much may happen there, and I want to know what's going on.
But my cronjob looks like this:
#-----------------
0 5 * * * /usr/bin/apt-get update && /usr/bin/apt-get dist-upgrade -y -d >/dev/null
#-----------------
-y: say yes to every question
-d: only download, do not install

so when I start upgrading the packages all are already localy available, no need to wait for download
Guest
 

Postby lacek » 2004-05-10 10:24

Not bad idea, however, I think that the -y option is safe for most automatic updates. Only trivial questions will be answered, and in addition, if you don't redirect the output to /dev/null, then cron will drop you a mail each day in which you can see if any errors occured during the upgrade.
lacek
Moderator Team Member
 
Posts: 769
Joined: 2004-03-11 18:49
Location: Budapest, Hungary

Postby hogehoge » 2004-05-16 02:34

how about just using cron-apt package? is there any problem with it.

$ apt-cache show cron-apt
(snip)
Description: Automatic update of packages using apt
This package contains a tool that is run by a cron job
at regular intervals. By default it just updates the package list and
download new packages without installing. You can instruct it to run
anything that you can do with apt-get.
.
It also sends mail (configurable) to the system administrator on
errors.
.
Observe that this tool is a security risk, so you should not set it
to do more than necessary (automatic upgrade of all packages is NOT
recommended).
hogehoge
 


Return to General Questions

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable