How to schedule task using Crontab- UNIX
Crontab: It is a process which executes commands at specific dates and times. You can use this to schedule activities, either as one-time events or as recurring tasks.
You should log in with superuser to add or remove any entries in this file.
With superuser execute
crontab -e
This will open a file for you, add your task in it and save it.After defined time the task will be performed.
You should log in with superuser to add or remove any entries in this file.
With superuser execute
crontab -e
This will open a file for you, add your task in it and save it.After defined time the task will be performed.
Suppose you want some shell script to be executed after every minute make an entry like this * * * * * /user/tools/test.sh Various Options that can be used with crontab: crontab [-u user] [-l | -r | -e] [-i] -u specifies the user’s crontab to be manipulated. This is usually used by root to manipulate the crontab of other users or can be used by you to correctly identify the crontab to be manipulated if you have used the su command to assume another identity. -l list the current crontab file -r remove the current crontab file -e edit the current crontab file using the text editor specified by the EDITOR environment variable or the VISUAL environment variable -iThis option modifies the -r option to prompt the user for a 'y/Y' response before actually removing the crontab. Below you can see what kind of values and range "*" at different positions can have, using it you can customize the execution of your task. * * * * * command to be executed
┬ ┬ ┬ ┬ ┬
│ │ │ │ │
│ │ │ │ │
│ │ │ │ └───── day of week (0 - 7) (0 or 7 are Sunday, or use names)
│ │ │ └────────── month (1 - 12)
│ │ └─────────────── day of month (1 - 31)
│ └──────────────────── hour (0 - 23)
└───────────────────────── min (0 - 59)
|
Comments
Post a Comment