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:
[2014-03-03] | [Open System-Linux] |
Working with VI Editor: Basic and Advanced |
[2014-10-26] | [Open System-Linux] |
XMLLINT command in linux : a validating XML parser |
[2014-11-19] | [Open System-Linux] |
ETHTOOL : A tool in Linux to display or change ethernet card setting |
[2014-10-04] | [Open System-Linux] |
SYSCTL : A command to configure kernel parameters at runtime in linux |
[2014-04-24] | [Open System-Linux] |
Addition of two numbers using shell scripting in UNIX |
Total comments: 0 | |