9:07 PM crontab: A command in linux to automatically start/repeat a process at certian time and interval | ||||||||||||||||||||||||||||||||||||||||
crontab - A command to manage crontab files for each users and schedule commands ans other scripts.
DESCRIPTION It is meant to be used for scheduling re-occurring jobs. If you want to schedule a job for one time exection, you should use at command in Linux. Each user can have their own crontab, and though these are files in /var, they are not intended to be edited directly. Related files: /etc/cron.allow, /etc/cron.deny To List the cronjobs for a user
The -l option causes the current crontab to be displayed on standard output. To see cronjobs og other user you can use -u option but you must be superuser to do so.
Delete the cronjobs for a user
The -r option causes the current crontab (cronjobs of current user)to be removed. The format to create a new cron:
To edit the crontab of a user: Eg.
To check if the cronjobs executed or are running If you are a root user, you can see and edit the cron job of other users.
crontab -u someUser -e
The above command will view/edit the corn jobs of someUser.
Example 2:
Suppose you want to delete some log files from your home directory at every friday of the month at 23:59. How will you do this? Simply type below line in your crontab:
59 23 * * 5 rm *.log
Example 3:
Suppose you want to start a script at 06:10 pm at the end of each month, you can use below cron:
10 18 * * * /path-of-script/script.sh
To run a command every one minute
Though this could not be the requirement, but just for understanding, below line in crontab will cause the CMD to run every minute.
* * * * * CMD
To run a command or script every 5 minute continuously */n in the first field (Minute field) means that the command will be execcuted every n minutes. For eg. */5 * * * * CMD So, the above cron will run the CMD every 5 minutes. To schedule a script/command to execute twice or thrice a day. 0 8,10 * * * CMD The above cron means the CMD will execute at 8:00 AM as well as 10:00 AM everyday(on weekend also) To schedule a script/command to execute in period ranging from one to another. Lets say we want to execute a command starting at 8: 00 AM till 11:00 AM. So, the value '8-11' in the hour field means the command will be executed at 8 AM, 9 AM, 10 AM and at 11 AM. Eg. 0 8-11 * * * CMD Now lets see some special cronjobs: These special time specification "nicknames" are supported, which replace the 5 initial time and date fields, and are prefixed by the '@' character:
| ||||||||||||||||||||||||||||||||||||||||
|
Related blogs
You may also like to see:
[2016-05-24] | [Open System-Linux] |
FACTER command in Linux : showing system facts |
[2015-09-09] | [Open System-Linux] |
Some funny and cool commands in Linux |
[2015-07-12] | [Open System-Linux] |
EGREP or extended grep in Linux to search patterns |
[2017-08-22] | [Open System-Linux] |
Difference between tailf and tail -f in Linux |
[2014-12-16] | [Open System-Linux] |
CUT command in Linux : cut the file vertically |
Total comments: 0 | |