Welcome to the Telecom world....

Hi All, Trying to make this Blog as learning Space for Telecom Protocols & Basic Programming Stuff. U will find Lots of Grammatical & Spelling mistakes. But who cares 4 that... Idea behind This: To share daily technical stuff as learning lessons...

Wednesday, March 28, 2007

Crontab Functionality

Hi,
Here i m with littel Unix Stuff.

Let's Talk About Unix CRON Jobs.

Crontab ( Cron Table ) Used to Schedule Commands to run at later time.

U Can Find info by Giving man crontab, Here I m giving some info about it.

You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow.
If that file does not exist,
you can usecrontab if your name does not appear in the file /usr/lib/cron/cron.deny.
If only cron.deny exists and is empty, all users can use crontab.
If neither file exists, only the root user can use crontab.

Options for Crontab
----------------------------------------------------------------------------
crontab -e To Edit crontab file.
crontab -l To Display crontab file.
crontab -r Remove crontab file.
----------------------------------------------------------------------------

A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.

Syntex For Crontab is

* * * * * command to be executed

U Can replace 1st * with: hour (0 - 23)
U Can replace 2nd * with: min (0 - 59)
U Can replace 3rd * with: day of month (1 - 31)
U Can replace 4th * with:month (1 - 12)
U Can replace 5th * with:day of week (0 - 6) (Sunday=0)

Example for the Crontab :

30 23 * * * rm /home/user/tmp/*

->it Indicates that, At 23:30 Daily all files from folder /home/user/tmp/ will be removed.


30 23 * 10,12 1-5 rm /home/user/tmp/*

->it Indicates that, At 23:30 every weekdays (Mon-Fri) in Oct & Dec all files from folder /home/user/tmp/ will be removed.

Note: U Can put # as a 1st Character of line & that line will not considered as Cron Job.

No comments: