Re: Problems with Hourly Cron Job
Originally Posted by
noloader
$ cat /etc/cron.hourly/hourly-update.sh
#!/bin/bash
/usr/bin/apt-get clean
/usr/bin/apt-get autoclean
/usr/bin/apt-get update
/usr/bin/apt-get upgrade -y
$
Tellya how I do it - I run it as a system cron job in /etc/crontab. Looks like this and runs every two hours -
Code:
# apt update
0 */2 * * * root apt-get update
It's your machine and you can do what you like but I'd recommend pretty strongly against running apt-get clean or apt-get upgrade as a scheduled task.
Occasionally an update will break a machine - it's happened to me several times. If you don't know *what* got updated you'll play hell troubleshooting it - you could look in apt's log but that's kind of a pain especially if your GUI is broken
If you're getting anything from a ppa or otherwise outside of *buntu's repositories an automatic upgrade is an accident waiting to happen
Also, if you're running apt-get clean there's no reason to run autoclean as clean will have removed all your packages and there won't be anything for autoclean to do.
But - do you really want to do this? Suppose one of these unattended upgrades breaks networking - then you won't be able to reinstall the package unless you download it on another machine or run a live CD to download and reinstall the packages and all their dependencies. If an automatic upgrade *does* break your machine you won't have the package files to reinstall anything.
Hard drives are cheap - it's just my preference but I prefer to have installed packages available so I'm not dependent on a network connection to reinstall them. You might consider running autoremove as a cron job instead of clean or autoclean.
Anyway, it's your machine and your choice. Let's just say I speak from experience when I say maybe automated upgrades aren't a great idea
cheers -
Last edited by wizard10000; February 21st, 2011 at 12:58 PM.
we don't see things as they are, we see them as we are.
-- anais nin
Bookmarks