Google it ....

Showing posts with label scheduler. Show all posts
Showing posts with label scheduler. Show all posts

Friday, June 8, 2012

How to use crontab in linux

Cron is the time-based job scheduler in Unix-like computer operating systems. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate system maintenance or administration.
crontab commands:
crontab -e      Edit your crontab file, or create one if it doesn’t already exist.
crontab -l      Display your crontab file.
crontab -r      Remove your crontab file.
crontab -v      Display the last time you edited your crontab file. 
                (This option is only available on a few systems.)

A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.
*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

examples:
min  hour  day/month    month    day/week  Execution time
30  0  1      1,6,12  *  – 00:30 Hrs  on 1st of Jan, June & Dec.
0  20  *        10       1-5  – 8.00 PM every weekday (Mon-Fri) only in Oct.
0  0  1,10,15       *  *  – midnight on 1st ,10th & 15th of month
5,10  0  10        *  1  – At 12.05,12.10 every Monday & on 10th of every month

create a cron job:
su - oracle
crontab -e
--add the following line :
00 13 * * * /u01/scripts/Incr0.sh

this script will run at 1:00 PM everyday.

after edit crontab file reload cron service
su - 
service crond reload

that's all. :)