Auto update an debian Server with Aptitude

How to keep software up-to-date automatically on Ubuntu Server using Aptitude

Usual disclaimer

This article is provided as it and no responsibility will be taken for things going wrong. Tested on Ubuntu 8.10 server.

Using Aptitude

If you've ever tried out Ubuntu you'll probably know what aptitude is and how to manage packages. Updating your system is as simple as sudo aptitude udpate && sudo aptitude upgrade

This updates the package lists and presents any upgrades.

Automating the process

Wouldn't it be easier if you could automate this and forget about it? That way your server can stay up to date without you ever having to worry about it. Create a file called autoupdate.sh and put the following into it:

#!/bin/bash

# A script to run Aptitude and install any upgrades automatically. 
# Add this to /etc/cron.daily to run the script every 24 hours. 

# This prevents "TERM is not set, so the dialog frontend is not usable." error
PATH="$PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"

aptitude update
aptitude safe-upgrade -y
aptitude autoclean

To run this script daily move it to /etc/cron.daily (making sure it is executable).

chmod +x autoupdate.sh
sudo chown root:root autoupdate.sh
sudo mv autoupdate.sh /etc/cron.daily 



test
cd /etc/cron.daily ./autoupdate.sh

The update will run automatically once a day ensuring you stay up-to-date.

Checking logs

You can keep a check on packages that have been installed and removed via the log file that Aptitude generates.

sudo tail -n 30 /var/log/aptitude

If you want to check that an upgrade has been applied you can search for it like this

sudo cat /var/log/aptitude | grep -A 20 -B 20 php5

Or you can check the currently installed version using (this example is php5)

aptitude show php5
Last modified onMonday, 13 May 2013 08:48

( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169
Call Stack
#TimeMemoryFunctionLocation
10.0013412504{main}( ).../index.php:0
20.13144262472Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.13144262472Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.442011453376Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.443111477704Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.444411533032Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.444711560432require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.453911960064K2ControllerItem->execute( ).../k2.php:64
90.453911960064K2ControllerItem->display( ).../BaseController.php:710
100.464512610768K2ControllerItem->display( ).../item.php:78
110.464512610768K2ControllerItem->display( ).../controller.php:19
120.469112981808Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.471713002176K2ViewItem->display( ).../ViewController.php:102
140.582815838680K2ViewItem->display( ).../view.html.php:742
150.582915838680K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.586016011616include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701
  • Published in Debian
  • Read 1209 times
More in this category: « 升级 Debian

( ! ) Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478
Call Stack
#TimeMemoryFunctionLocation
10.0013412504{main}( ).../index.php:0
20.13144262472Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.13144262472Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.442011453376Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.443111477704Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.444411533032Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.444711560432require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.453911960064K2ControllerItem->execute( ).../k2.php:64
90.453911960064K2ControllerItem->display( ).../BaseController.php:710
100.464512610768K2ControllerItem->display( ).../item.php:78
110.464512610768K2ControllerItem->display( ).../controller.php:19
120.469112981808Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.471713002176K2ViewItem->display( ).../ViewController.php:102
140.582815838680K2ViewItem->display( ).../view.html.php:742
150.582915838680K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.586016011616include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701
back to top