Automate your Ubuntu updates with a simple command.

Nov 17

One of the very annoying things about having multiple Linux systems (or virtual machines) in the house is that you constantly need to keep them patched and updated. Sure, they are not as vulnerable as some Windows systems but it is still good practice to keep your systems nicely patched. So instead of doing sudo apt-get upgrade every time (or worse , getting a popup from the update manager while you are just in the middle of watching your favorite Youtube video about bunnies ) .. lets schedule this.

Scheduling things is not bad , but you have to be careful just WHAT you want those systems to do. You don’t want to wake up one morning and see that your LTS (long term support) workstation has just done a make-over and rolled onto the cutting edge version of the new release of your operating system. So kernel and distro upgrades should not be a part of your schedule.

The command we choose to use is Aptitude. With the following string you can do an update and upgrade on the same line.

/usr/bin/aptitude -y update && /usr/bin/aptitude -y safe-upgrade

So what does it do ?

“-y” makes sure that you don’t have to type YES at the end of the command.

” safe-upgrade” means that kernell or distro upgrades are a “nono”

“&&” links the commands together.

How to schedule it.

Simple. Log in as a user with root access and type “crontab -e”

next ad the following line to your cron

0 1 * * * /usr/bin/aptitude -y update && /usr/bin/aptitude -y safe-upgrade

Thats it. Now the the upgrade is executed every single night at 1 am. 

source. Kevin van Zonnevelds blog.

 

Related Posts

Kwtv303 : "Twittering from the command line".

May 25

 

We show you a very simple tool how to use twitter from the command line, teach you how to schedule your tweets with Cron and create your own personal twitter assistant. With some cool and smart hacks for anyone to master we create your own virtual twitter butler (or imaginary friend)

Shownotes.


Related Posts


Letting Windows XP do its own maintenance.

May 29

I don't know about you .. but i am out of here.

Computer maintenance can be a tedious task, and somehow Windows Pc's can't get enough of it. Wether I open up a computer magazine or listen to a podcast about Windows its always spyware this and scandisk that etc. Now as for spyware and such , I completely understand , there is a lot of crap out there, but standard maintenance tasks on your computer are not something you should worry about. One of the images that shoots to mind is this guy sitting in front of his computer WAITING for the de-fragmentation to complete that he started about an hour ago. Meanwhile he is just sitting there , like its some kind of laundry machine and he has to get his socks back. Not for me No-oh! If I tell my pc to clean up his room ? He better do it all by himself. Here are a few tricks that you can use to have your pc do 'his on thang” on “his own time”.

Step One ! Pick a free spot in your calendar.

Don't do computer maintenance at the peak of your day or while you have five little brothers and sisters waiting in line to play World of Warcraft. Do it at night . And don't stay up for it , let the computer do it. So choose a time when you don't need your computer and dive into the BIOS ( Press delete or F2 when the computer is starting up.) Most BIOS's (is that plural ?) these days have an “automatic power up” option that you can set. This means you can let your computer power up automatically at a certain time without you having to get up and press the button. Set the auto power up to a certain time and day of your choice.

Step Two ! Log in automatically.

tweakuiIts not the best way of doing things securely , but if your computer is just parked in your room you can enable auto-login. One of the programs you can use for this is TWEAK-UI   it will not only give you the option to auto-log-on as a certain user , but also lots of other cool tweaks.Are you afraid somebody is gonna try to access your computer while its unguarded ? No worries , just set the screen-saver to 1 minute and password protect it.

Step three ! Let the games begin.

Once your computer is securely logged in you can let him do its daily chores.Open a text-file and start typing.

at 01:00 /every:M,F defrag c:

The AT command lets you schedule certain tasks at certain times. In the example above it will run the command DEFRAG C: (de-fragment your hard-drive) every monday and friday.

at 02:00 /every:M,F defrag d:

Identical stuff , this time for the D drive, an hour later.

TIP : if you want to save yourself a lot of pain in the but , make a separate partition on your hard-drive where you set your windows swap file. This will greatly increase your de-fragmentation times and speed up your pc.

Next up you might wanna do a little cleaning up of your hard-drive. Its never bad to do a anticipative scandisk before your favorite telletubie pictures get lost on that runt hard-drive cluster.  Now you can't do a scandisk (or check-disk ) on a drive thats currently in use , just like you can't vacuum the rug you are standing on. But again , that is not a problem. When you run the CHKDSK command in Windows and point to a busy drive , Windows will do the operation next time the drive is free ( that is the next time the computer boots up). So once again , take the AT command and type up these little lines of code.

at 01:30 /every:F chkdsk c: /f /r

This means : every friday clean up my drive , repair the data on broken clusters and move on. 

And last but not least , you have to shut the machine down. You don't have to get up to do that , just use the shutdown command as follows.

at 01:45 shutdown -s -f

ShutdownThis means : at a quarter to two , shutdown the computer. (and force close all open programs)A nice tip you might want to remember is that you can enter the shutdown command in the RUN box in your start menu, for example, your computer is burning a cd, its still gonna be an hour before its done. But you wanna go out and grab a burger and don't want your computer running in vain all night. Just type shutdown -t 3600 and hit enter. Here 3600 stands for the number of seconds  the computer waits before shutdown.
And thats it. Just type all the commands in a txt file, save it as maintenance.bat and either drag it to your startup folder so it runs automatically every day , or click on it to run everything manually. You can find more  examples of the AT command  here . Now go outside and play … and let technology work for you !

Related Posts