Crontab configuration in Linux


CRONTAB

Crontab is the default scheduling Application/program in most of the Linux/Nix boxes.
Crontab is define as scheduling of programs/scripts/applicaions with out administrator interventions
Crontab = (Cron)oligical+(tab)le nothing but time table for executing some scripts at that point of time

So where we requre crontab?
where there is no need for admin intervetions such as taking dialy backups sending mails to perticular users monitoring network.

So coming to scheduling task crontab uses clock daemon (/usr/sbin/cron or perhaps /usr/sbin/crond) that executes commands at specific times. and corn tables for each user is located in /var/spool/cron/ with their names
suppose you want to see cron table for root(cat /var/spool/cron/root)

Crontab file content

The content of the file can be devide in to 6 feilds(first 5 for specifing time and last one for executing scripts/app etc)
The first five fields are separated by either a space or a tab and represent the following units, respectively:

* minutes (0-59)
* hour (0-23)
* day of the month (1-31)
* month of the year (1-12)
* day of the week (0-6, 0=Sunday)


Configuration of crontab for user

Step1:Creating crontab for a user

#crontab -e -u username
-e is for specifing editing and -u for specifing username when you are scheduling crontabs for other users
if users want to schedule their own he can just give (crontab -e)
Example:

I will take one example here to explain crontab,suppose I want to execute one script located in /var/test/script.sh and save the output to /temp/script.out should be executed every 10th of each month at 9:43pm

#crontab -e -u surya

so here it will open a temporary in /tmp folder

43 21 10 * * /var/test/script.sh > /temp/script.out

here * in month field and week field indicates any month and any week execute this script

after entering the values save and exit the file, A file will be created in as /var/spool/cron/surya with the above content

Step2:seeing crontab for a perticular user

#crontab -l -u username

Example

#crontab -l -u surya

If you are a user and want to see your crontab you can just give (crontab -l)

Step3:Removing crontab for perticular user

This can be acheived in two ways
1)removing all the crontab entries for a perticual user

#crontab -r -l username

Example

#crontab -r -l surya

2)removing one task for perticual user,for doing this we have to edit the crontab

#crontab -e -l username

Please see here some of the crontab issues

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Related Posts by Categories



    0 comments:

    Archive

    Translate this page

     

    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here