Scheduling tasks in linux for automating with crontab

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.🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s