4.6. Cron Jobs

The Cron Jobs module is used for editting the crontab on your system. Cron is a daemon that runs constantly on most Unix systems, and allows users and the adminstrator to run specified tasks automatically at selected times. Ordinarily, crond is configured from one or more configuration directories in /etc/cron.d, and on Red Hat Linux systems and some other Linux distributions crond draws its configuration from /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, and /etc/cron.monthly. Note that even on Red Hat and similar systems, /etc/cron.d still exists and can be used just as on any other Unix system.

Configuration of crond is much simplified by use of the Webmin module. To create a new cron job, click Create a new cron job. The Create Cron Job page allows you to select the user that the cron job will be run as, thereby limiting its permissions to those of the selected user. As in all permissions situations, it is best to choose a user with the least permissions required to actually accomplish the task needed. There are fields for entering Command to be executed, as well as for any Input to command you might have.

Figure 4-6. Create Cron Job

Create Cron Job

In the above figure, I've created a cron job that is run as a user named backup (a user I've created just for such tasks). The job is Active, so it will run at the specified times. The command that is being run is a simple tar commandline to backup my complete /etc directory to a tarball in /home/backup. Not terribly sophisticated but gets the job done, without much complexity. And a simple periodic backup of important files is far better than no backup at all.