Clan x86

Technical (Development, Security, etc.) => Unix / Linux Discussion => Topic started by: Joe on March 28, 2006, 07:45:26 AM

Title: Joe <3 cron!
Post by: Joe on March 28, 2006, 07:45:26 AM
Yup. I'm not sure it if's just debian/ubuntu, or it's for all of Linux (I assume the latter), but it's a scheduling daemon. Right now, here's root's crontabs.

30 22 * * * echo "Starting dist-upgrade: $(date)" >> /tmp/update.log && /usr/bin/apt-get update -y && /usr/bin/apt-get dist-upgrade -y


From the Ubuntu Wiki Page (https://wiki.ubuntu.com/CronHowto?highlight=%28cron%29) about cron, it says that the first five spaces (here: "30 22 * * *") specify, in order, the *minute*, *hour*, *day of month*, *month* and *day of week*.

So I have these tasks scheduled to occur at 10:30 (2230 military time) each night:
Make a note about system upgrade in /tmp/update.log
Get list of latest updates (apt-get update -y)
Download + install them (apt-get dist-upgrade -y)
Title: Re: Joe <3 cron!
Post by: Newby on March 28, 2006, 08:40:02 AM
That's ridiculous. That's gonna be such a bandwidth whore.

Good idea though, if you can afford the bandwidth/CPU speed you'll be eating 10:30 each night downloading and installing shit. :P
Title: Re: Joe <3 cron!
Post by: rabbit on March 28, 2006, 09:44:43 AM
If your distro gets minor updates every now and then, once a week is best.  Otherwise I'd personally set it to once a month or quarter.
Title: Re: Joe <3 cron!
Post by: iago on March 28, 2006, 02:47:12 PM
Any distro CAN run cron, and every distro that I'm familiar with does. 

On darkside, I have a nightly crontab to back up key databases and files. 
Title: Re: Joe <3 cron!
Post by: Joe on March 28, 2006, 05:15:38 PM
Quote from: Newby on March 28, 2006, 08:40:02 AM
That's ridiculous. That's gonna be such a bandwidth whore.

Good idea though, if you can afford the bandwidth/CPU speed you'll be eating 10:30 each night downloading and installing shit. :P

I can EASILY afford the CPU speed (2.8GHz runs Linux like nobody's business), and afford the bandwidth (nobody will be awake until 6:30 the next morning). And the only time I'll be downloading is if an update comes out. Apt-get update will check hit/miss on the repository lists, and if theres a miss THEN it downloads the list, and apt-get dist-upgrade will only download if everything isn't current.

Quote from: rabbit on March 28, 2006, 09:44:43 AM
If your distro gets minor updates every now and then, once a week is best.  Otherwise I'd personally set it to once a month or quarter.

It's pretty much configured for when I switch to dapper drake (development version), so I don't get piled up on. But yeah, this is a bit overkill.
Title: Re: Joe <3 cron!
Post by: Newby on March 28, 2006, 06:33:42 PM
I should do something similar to this with FreeBSD && portupgrade.
Title: Re: Joe <3 cron!
Post by: Joe on March 28, 2006, 06:59:53 PM
Btw, this idea is copywrite 2006 Joe. (kidding, but still.. royalty please).
Title: Re: Joe <3 cron!
Post by: Sidoh on March 29, 2006, 12:19:15 AM
Quote from: iago on March 28, 2006, 02:47:12 PM
On darkside, I have a nightly crontab to back up key databases and files. 

Hehe, I do the same on deepthought.  Crontabs are so more straightforward and flexible than Windows' "Scheduled Tasks."
Title: Re: Joe <3 cron!
Post by: Ergot on March 29, 2006, 12:54:04 AM
I use cron to stop my computer from flying ahead 1 minute every week >:\
Title: Re: Joe <3 cron!
Post by: Joe on March 29, 2006, 09:59:59 AM
Why the hell would it do that? =p

EDIT -
My computer is sync'd with USAC on startup. Not that I need to restart very often.
Title: Re: Joe <3 cron!
Post by: Sidoh on March 29, 2006, 10:49:13 AM
Quote from: Ergot on March 29, 2006, 12:54:04 AM
I use cron to stop my computer from flying ahead 1 minute every week >:\

I have a crontab to do that as well. :)

Quote from: Joe on March 29, 2006, 09:59:59 AM
Why the hell would it do that? =p

EDIT -
My computer is sync'd with USAC on startup. Not that I need to restart very often.

/me shrugs.

His CPU is in relative motion, I'd say. ;)
Title: Re: Joe <3 cron!
Post by: iago on March 30, 2006, 12:13:12 AM
Quote from: Ergot on March 29, 2006, 12:54:04 AM
I use cron to stop my computer from flying ahead 1 minute every week >:\

Speaking of that, what's the command to update to a NTS server?  Darkside tends to lose time, so it would help to update it nightly. :)
Title: Re: Joe <3 cron!
Post by: Ergot on March 30, 2006, 12:39:32 AM
# ntpdate pool.ntp.org
Title: Re: Joe <3 cron!
Post by: Joe on March 30, 2006, 07:49:35 AM
Hehe @ darkside being to slow to even keep track of time.
Title: Re: Joe <3 cron!
Post by: Sidoh on March 30, 2006, 10:24:07 AM
Quote from: Joe on March 30, 2006, 07:49:35 AM
Hehe @ darkside being to slow to even keep track of time.

It happens.  It's because his CPU is in relative motion.  Duh.
Title: Re: Joe <3 cron!
Post by: iago on March 30, 2006, 01:11:07 PM
Quote from: Joe on March 30, 2006, 07:49:35 AM
Hehe @ darkside being to slow to even keep track of time.
The time isn't kept track of by the CPU, it's an independent component in the BIOS.  And it's a really old computer, so it's got a crappy BIOS. 
Title: Re: Joe <3 cron!
Post by: Sidoh on March 30, 2006, 01:14:39 PM
Quote from: iago on March 30, 2006, 01:11:07 PM
The time isn't kept track of by the CPU, it's an independent component in the BIOS.  And it's a really old computer, so it's got a crappy BIOS. 

Obviously, I was testing Joe.  I meant that your BIOS is in relative motion.

... >_>

I seriously kind of knew that (though I've never really worded it), since it's obvious that time is kept when the computer has no power.
Title: Re: Joe <3 cron!
Post by: Blaze on March 30, 2006, 03:41:00 PM
I always wondered why the forums time was always late 10-20 minutes every time I checked.   :)

I think auto-updating is a neat idea, for a server/testbox like BATSERVER which is currently Resting In Peices.
Title: Re: Joe <3 cron!
Post by: iago on March 30, 2006, 08:21:24 PM
Quote from: Sidoh on March 30, 2006, 01:14:39 PM
Quote from: iago on March 30, 2006, 01:11:07 PM
The time isn't kept track of by the CPU, it's an independent component in the BIOS.  And it's a really old computer, so it's got a crappy BIOS. 

Obviously, I was testing Joe.  I meant that your BIOS is in relative motion.

... >_>

I seriously kind of knew that (though I've never really worded it), since it's obvious that time is kept when the computer has no power.

I wasn't listening to you, but yeah, if the bios is moving then the whole computer is.  Maybe I should stop it from vibrating to fix the clock?
Title: Re: Joe <3 cron!
Post by: iago on March 30, 2006, 08:29:42 PM
All right, darkside's time should be fixed nightly now. 

The script is super simple:

#!/bin/sh

DATE="/bin/date"
NTPDATE="/usr/sbin/ntpdate"
NTPSERVER="pool.ntp.org"

$DATE
$NTPDATE "$NTPSERVER"
$DATE


Notice that I like to store program names in variables.  Most people don't do that, but I find it helpful in case a program moves.