View Single Post
Old 09. Dec 2009, 03:37 AM   #1 (permalink)
Senior Member
debtboy's Avatar
Join Date: May 2009
Location: ~/
Posts: 128
Default The Cron Basics:

Brief overview of cron, crontab and anacron.

Cron is a background daemon which executes scripts (cronjobs) at predetermined times or intervals.

Crontab is a configuration file that allows you to select and schedule when, or at what interval, these cronjobs will run at.

Anacron is smart program that works in conjunction with cron, but taking into accout that the system may be shut down from time to time or on a regular basis. Cron assumes that the system will be running for every scheduled job and if it's not then that job will not execute, while anacron takes into account that the system may be off and it executes each cronjob as close to the time as possible when the system is started.

As you can see from this Synaptic package manager image, cron and anacron are already installed, but if they weren't, a few simple clicks in synaptic or an apt-get statement would take care of it.

The little person that appears to be sitting in the image is one of the many desktop mascots (a feature of my current Linux distro Mangaka-chu).

Lets start with the cron daemon...
First we will determine if cron is currently running in the background.
I will run a process command for the user root and pipe that into grep, looking for the "cron" pattern.

As you can see from this image "cron" is indeed running.
If it wasn't I run the following command as root or (sudo)

NOTE: this is on my current Mangaka-chu system (Debian/Ubuntu based)

# /etc/init.d/cron start
$ sudo /etc/init.d/cron start

Alternatively stop and restart also work using the same syntax.

The cron daemon will execute cronjobs under the permission of the crontab creator, most likely, you.
Depending on you system, you may or may not have a /etc/cron.deny or a /etc/cron.allow file(s). These file(s) control a user's ability to create/edit crontab files.
[I][B]Linux, the choice of a GNU generation[/B][/I]
debtboy is offline   Reply With Quote