Support Forum Articles File Help Startup DB Tips Service DB Hijack This! Analyzer


Crontab setup and help

We've been showing people how to automate various tasks in windows for quite a while now. I would like to show people how to automate tasks in Linux too. The first thing you'll need to know is about Cron jobs.

Minute, Hour, Day of the Week, Day of the Month, Month are all options that you can set.

crontab -l will list all of the crontabs setup on your system already.
0 3 * * * /usr/local/sbin/dumpdatabases
This is my scheduled database backup. This task is scheduled to run every day at 3AM. Below is a breakdown of everything.

Full File Location

Minute: 0-59 are valid
Hour: 24 hour clock (army time)
Day Of Month: 1-31 are valid
Month: 1-12 are valid (1 is January, 2 is February)
Day Of Week: 0-6 are valid (0 is Sunday, 1 is Monday)
Full File Location: Make sure you put the FULL path to the script you're automating.

What is the * for? This means to run it on every option for that field. In this example it is run every day of every week of every month at 3:00AM.

Creating a new Crontab

Instead of going over locating your crontab file I'm going to tell you to issue the crontab -l command and copy all of it's contents. Now create a .txt file. In this example I'm using cron.txt. (If you had 0 entries when you issued crontab -l then skip this part) Paste the contents of crontab -l into this cron.txt file. Insert any additional lines that you'd like to have and then issue the command crontab cron.txt and you're done! Now anytime you'd like to add additional entries simply edit cront.txt and issue crontab cron.txt again to update any changes that you made.

Written By: Martin Krohn
Date: 6-27-04
Printer Friendly

Article Index:
Talk About it! -->