Tuesday, March 27, 2007

Quick Intro to Crontab

This is another *nix power tool that is a must use. Scheduling jobs with crontab is so trivially easy.

Type
crontab -e
on your command prompt

This should bring up a window looking like this:

# m h dom mon dow command

Its stands for m-minute, h-hour of day (24 hr fmt), day of month, month, day of week, command.

Thus if my crontab looks like
# m h dom mon dow command
30 3 * * * rm -rf *

It tells it to run "rm -rf * " (Jeez! I am kidding, DON'T PUT THIS in your crontab) at 3.30 AM every day...

If I wanted to run the job say twice every day, I would put in
30 3,13 * * * rm -rf *
which will run the job at 330 AM and 130 PM.

That's it!

No comments: