A Short Introduction To Cron Jobs

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 03/08/2009

This article is a short introduction to cron jobs, their syntax, and how to set them up. A cron job is a scheduled task that is executed by the system at a specified time/date.

I do not issue any guarantee that this will work for you!

1 crontab

The command to create/edit, list, and remove cron jobs is crontab. If you call it with the -u option, it specifies the name of the user whose crontab is to be tweaked. If this option is not given, crontab examines “your” crontab, i.e., the crontab of the person executing the command. If you are looged in as root and run crontab without -u, then root’s crontab is listed/modified/removed. If you are logged in as exampleuser and run crontab without -u, then exampleuser‘s crontab is listed/modified/removed.


crontab -l

lists the cron jobs of the user as that you are currently logged in:

server1:~# crontab -l
* * * * * /usr/local/ispconfig/server/server.sh > /dev/null 2>> /var/log/ispconfig/cron.log
30 00 * * * /usr/local/ispconfig/server/cron_daily.sh > /dev/null 2>> /var/log/ispconfig/cron.log

crontab -u exampleuser -l

lists all cron jobs of exampleuser.

crontab -e

let’s you create/modify the cron jobs of the user as that you are currently logged in (I’ll come to the syntax in the next chapter).

crontab -u exampleuser -e

let’s you create/modify the cron jobs of exampleuser.

crontab -r

deletes all cron jobs of the user as that you’re currently logged in.

crontab -u exampleuser -r

deletes all cron jobs of exampleuser.

If you have written your cron jobs to a text file, you can use the text file to create the cron jobs. For example, let’s assume you have created the text file /tmp/my_cron_jobs.txt

vi /tmp/my_cron_jobs.txt

… with the following contents:

30 00 * * * /path/to/script

You can create a cron job from that file as follows:

crontab /tmp/my_cron_jobs.txt

(Or for exampleuser:

crontab -u exampleuser /tmp/my_cron_jobs.txt


Please note that this will overwrite all previously created cron jobs – if you’ve already created some cron jobs, you better use crontab -e and add the new cron job manually.


man crontab

to learn more about the crontab command.

2 Cron Job Syntax

A cron job consists out of six fields:

<minute> <hour> <day of month> <month> <day of week> <command>

field          allowed values
—–          ————–
minute         0-59
hour           0-23
day of month   1-31
month          1-12 (or names, see below)
day of week    0-7 (0 or 7 is Sun, or use names)

// <![CDATA[// <![CDATA[

// ]]>

// <![CDATA[// <![CDATA[
if (typeof ord=='undefined') {ord=Math.random()*10000000000000000;}
// ]]>// <![CDATA[// <![CDATA[
// ]]>// <![CDATA[// &lt;a target=”_blank” href=”http://ad.doubleclick.net/click%3Bh=v8/3880/3/0/%2a/x%3B215487674%3B0-0%3B0%3B37706476%3B4307-300/250%3B31741543/31759419/1%3Bu%3Didgt-97517877_1249433519%2C11228fcd2c86b5a%2Cvirtualization%2Cidgt.virtualization_H%3B%7Eaopt%3D0/ff/53/ff%3B%7Efdr%3D216157216%3B0-0%3B0%3B39511760%3B4307-300/250%3B31848342/31866218/1%3Bu%3Didgt-97517877_1249433519%2C11228fcd2c86b5a%2Cvirtualization%2Cidgt.virtualization_H%3B%7Eaopt%3D3/1/53/0%3B%7Esscs%3D%3fhttp://www.vwire.com/vwire.cfm”&gt;&lt;img src=”http://m1.2mdn.net/2251067/1-error_300x250_vR.jpg&#8221; width=”300″ height=”250″ border=”0″ alt=”” galleryimg=”no”&gt;&lt;/a&gt; &lt;a href=”http://a.collective-media.net/jump/idgt.howtoforge.en/article_above;sec=article;fold=above;tile=3;sz=300×250;ord=123456789?&#8221; target=”_blank”&gt;&lt;img src=”http://a.collective-media.net/ad/idgt.howtoforge.en/article_above;sec=article;fold=above;tile=3;sz=300×250;ord=123456789?&#8221; width=”300″ height=”250″ border=”0″ alt=””&gt;&lt;/a&gt; // <![CDATA[// <![CDATA[

// ]]>

When specifying day of week, both day 0 and day 7 will be considered Sunday.

A field may be an asterisk (*), which always stands for first-last.

Names can also be used for the “month” and “day of week” fields. Use the first three letters of the particular day or month (case doesn’t matter), e.g. sun or SUN for Sunday or mar / MAR for March..

Let’s take a look at the two cron jobs from the first chapter:

* * * * * /usr/local/ispconfig/server/server.sh > /dev/null 2>> /var/log/ispconfig/cron.log

This means: execute /usr/local/ispconfig/server/server.sh > /dev/null 2>> /var/log/ispconfig/cron.log once per minute.

30 00 * * * /usr/local/ispconfig/server/cron_daily.sh > /dev/null 2>> /var/log/ispconfig/cron.log

This means: execute /usr/local/ispconfig/server/cron_daily.sh > /dev/null 2>> /var/log/ispconfig/cron.log once per day at 00:30h.

The day of a command’s execution can be specified by two fields: day of month, and day of week. If both fields are restricted (i.e., aren’t *), the command will be run when either field matches the current time. For example, 30 4 1,15 * 5 would cause a command to be run at 4:30h on the 1st and 15th of each month, plus every Friday.

You can use ranges to define cron jobs:


1,2,5,9 – means every first, second, fifth, and ninth (minute, hour, month, …).

0-4,8-12 – means all (minutes, hours, months,…) from 0 to 4 and from 8 to 12.

*/5 – means every fifth (minute, hour, month, …).

1-9/2 is the same as 1,3,5,7,9.

Ranges or lists of names are not allowed (if you are using names instead of numbers for months and days – e.g., Mon-Wed is not valid).

1,7,25,47 */2 * * * command

means: run command every second hour in the first, seventh, 25th, and 47th minute.

Instead of the first five fields, one of eight special strings may appear:

string         meaning
——         ——-
@reboot        Run once, at startup.
@yearly        Run once a year, “0 0 1 1 *”.
@annually      (same as @yearly)
@monthly       Run once a month, “0 0 1 * *”.
@weekly        Run once a week, “0 0 * * 0”.
@daily         Run once a day, “0 0 * * *”.
@midnight      (same as @daily)
@hourly        Run once an hour, “0 * * * *”.

You can also use name=value pairs in a crontab to define variables for the cron jobs:

# use /bin/bash to run commands, instead of the default /bin/sh
# mail any output to exampleuser, no matter whose crontab this is
# set the PATH variable to make sure all commands in the crontab are found

* * * * * my_command

Please note: unless you set a PATH variable in a crontab, always use full paths in the crontab to make sure commands are found and can be executed. For example, instead of writing rsync, you should write /usr/bin/rsync. Use which to find out the full path of a program:

which rsync

server1:~# which rsync


man 5 crontab

to learn more about the cron job syntax.

Read more on Howtoforge.com


OpenVPN Server On CentOS 5.2

So your users need access to Exchange and data from outside your organisation. Sure you can set up RPC over HTTPS and various other tools to access the data. I just find OpenVPN very good, convenient and reliable.

And after battling to find a good simple HOWTO, I put this together. It’s a quick and nasty but it works!:)

Firstly, ensure you are root, and just in case the OpenVPN is not in the base repository, add the rpmforge repo (these steps you can find elsewhere).

Read more on Howtoforge.com

Configure HTTPD (Apache) for PAM Authentication for Backuppc

Recall that the reason for doing this Linux-Windows integration was to get the users of my Linux-based backup server to have web-based access to their files, from their Windows XP desktops.

I will not go into the details of configuring the BackupPC web interface. That’s extensively covered in the BackupPC documentation here.

Apache has an almost-annoyingly huge number of authentication mechanisms, but most people use password authentication based on an .htpasswd or .htaccess file. However, since all the users of my Linux-based backup system already had acounts on the ADS server, it seemed to make no sense to have to create a parallel authentication database for them. Not to think of the nightmare of synchronising the two databases when either or both change.

I’ll start by getting Apache to grant access only to users who authenticate on its host Linux box. Keep in mind though, that those users will actually be authenticating against an ADS database. This is made possible by PAM, and to make Apache authenticate using PAM, we must download and install the Apache mod_auth_pam module.

Read more on muyiwataiwo.com

BackupPC Setup Manual

July 2007 This how-to article is based on my experience setting up and maintaining a regular Ubuntu 7.04 install running as the backup server at UCSD. The clients varied in their OS’s; Mac OS X, Windows XP, Linux (Debian and Ubuntu). Except for the install commands (eg apt-get install), this instruction should work with other Linux distros.

Client Set Up

Please click the OS that you use to see the specific instructions.

If you have Cygwin installed or are planning on getting it in the future, please use the link for Win XP with Cygwin. If you do not know what Cygwin is, most likely you don’t have it. However, if you would like to find out, click here to find out.

Server Set Up

This manual is written for the administrator who will be setting up the backup server. You must have a root privilege. The server computer will be the computer that will do the backup and keep the backed up data.

Read more on taksuyama.com

Using Unison with BackupPC to backup laptops

These instructions are provided in the hope that they’ll be useful to others. If you find them useful, please drop me a note: stephen [at] physics.unc.edu. Similarly, if you implement this setup on platforms other than Windows and wish to contribute your code (either under GPL, or transferring copyright to me) please do so.

The Problem

One common problem plaguing IT professionals is how to backup data on laptops and other mobile devices. There is considerable value in mobile data, but many users seldom, if ever, bring their laptops back to the corporate or academic campus where it may be regularly backed up.

BackupPC is an excellent open-source product for backing up computers. It excels at backing up desktops and servers, but laptops (as moving targets) are especially difficult. By default, BackupPC can be configured to wake up periodically, say hourly, and look for laptops that have appeared on the network. This is not without issues (some of which can be worked around), but these are compounded when laptops do not have static IP addresses.

A better solution is to allow users to backup valuable data on the laptops on-demand. This page details my solution to do this.

Read more on www.physics.unc.edu

BackupPC Install Guide for Windows XP/Vista Clients

Author: Cody Dunne
Last Edited: 12/06/2008

Most of this guide is not original work, and is based substantially on the numerous sources available online for these tools. It does, however, combine many of the disparate sources for this information, add some of my own experience and insights, and provides an excellent backup scheme for Windows XP/Vista clients. Hopefully it will help other users in this process and prevent them from spending as much time getting it working as I did.

Read more on www.cs.umd.edu

BackupPC How-to on CentOS

Last modified on:
12-15-2008 – Created.

By: MaxHetrick

This guide will assist you in setting up BackupPC using the CentOS RPMs in the CentOS testing repository. It will not go into detailed explanations of all the possible BackupPC configurations. It will also assume that you’re setting up BackupPC to do backups across rsync. BackupPC is capable of archive, tar, smb, and rsyncd backups, but this guide will concentrate only rsync to other Linux hosts. BackupPC is heavily documented when it comes to configuration options, and the guide is present in the web interface. Also, BackupPC should reside on it’s own server, because Apache must be run as the BackupPC user created on the system which could affect regular webserver things.

Read mor on wiki.centos.org

Partitioning RAID / LVM on RAID

RAID devices can be partitioned, like ordinary disks can. This can be a real benefit on systems where one wants to run, for example, two disks in a RAID-1, but divide the system onto multiple different filesystems:

Read more on linux-raid.osdl.org

Installing PowerDNS (With MySQL Backend) And Poweradmin On CentOS 5.2

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 01/15/2009

This article shows how you can install the PowerDNS nameserver (with MySQL backend) and the Poweradmin control panel for PowerDNS on a CentOS 5.2 system. PowerDNS is a high-performance, authoritative-only nameserver – in the setup described here it will read the DNS records from a MySQL database (similar to MyDNS), although other backends such as PostgreSQL are supported as well. Poweradmin is a web-based control panel for PowerDNS.

I do not issue any guarantee that this will work for you!

Read more on Howtoforge.com

Set Up A Linux PlayStation 3 Media Server (CentOS 5.2)

Version 1.0
Author: Andrew Colin Kissa <andrew [at] topdog [dot] za [dot] net>
Last edited 25/01/2009


The Sony PlayStation 3 is a DLNA compatible device, DLNA is a framework where home electronics can share digital media and content seamlessly. This tutorial is a followup to the previous howto on Ubuntu. Given that I like most others use CentOS as their server distribution of choice, I find it fitting to run my DLNA server on it as well. Although several other open source media servers exist, I chose to use Fuppes due to its ease of use as well as built in support for transcoding.

By following this howto you will be able to create a server that will allow you to play digital media stored on the server via a DLNA capable device such as the Sony PS3, Nokia N95, etc.

Read more on Howtoforge.com