Crontab

Crontab useful keywords

In this short article I would like to remind you few useful keywords which you can use to describe your cron jobs in simple way.

Their names sufficiently describes how specified keyword works, but I prepared a short table with description where you can also find equivalent for keyword in regular “cron language” and how it acts.

Keyword Equivalent Description
@yearly 0 0 1 1 * Run job every year
@daily 0 0 * * * Run job every day
@hourly 0 * * * * Run job every full hour
@reboot Run job at system startup

To edit your crontab, you use:
crontab -e

To see actual crontab for your current user:
crontab -l

Here is a real-life example of keywords usage in crontab:

@daily /usr/sbin/cron-apt
@reboot /usr/sbin/cron-apt

It runs cron-apt (auto update tool for your aptitude) command every day and after every reboot.
You can read more about cron-apt here.

 

DD

How to automatically update your Ubuntu/Debian every day?

If you were ever tired of everyday manual update of your debian packages, we can recommend a very simple way to do it automatically every period you want.

There are several ways to do that, I’ll show you simplest one to do that.

There is a nice debian package in repo, which do all magic for you. Just simply install it:

sudo apt-get install cron-apt

Configuration file you can find in /etc/cron-apt .

Informations about writing config file are inside file:

/usr/share/doc/cron-apt/README.gz

The most common option for us will be sending mail after every upgrade error. To do that, add following lines to /etc/cron-apt/config:

MAILON=”error”

MAILTO=”email@domain.com”

Now, edit your crontab and add automatic update everyday:

crontab -e

Add this line to your crontab to run job daily:

@daily /usr/sbin/cron-apt

Save file and enjoy your auto-updating-everyday Ubuntu :)

DD