What is Crontab
Crontab is the default scheduling Application/program in most of the Linux OS
Crontab is defined as scheduling of programs/scripts/applications to run at defined intervels.
So where we require crontab?
where there is no need for admin interventions such as taking daily backups, sending mails to particular users, monitoring network etc.
Crontab file content
The content of the file can be devided in to 6 fields(first 5 for specifying time and last one for executing scripts/app etc)
The first five fields are separated by either a space or a tab and represent the following units, respectively:
* minutes (0-59)
* hour (0-23)
* day of the month (1-31)
* month of the year (1-12)
* day of the week (0-6, 0=Sunday)
Configuration of crontab for user
Example1:Creating crontab for a user
#crontab -e -u username
-e is for specifying editing and
-u for specifying user name when you are scheduling crontabs for other users
if users want to schedule their own he can just give (crontab -e)
Example:I will take one example here to explain crontab,suppose I want to execute one script located in /home/test/script.sh and save the output to /tmp/script.out should be executed every 22th of each month at 11:30pm
#crontab -e -u rahul
so here it will open a temporary in /tmp folder
30 23 22 * * /home/test/script.sh > /tmp/script.out
here * in month field and week field indicates any month and any week
execute this script
Example2: seeing crontab for a particular user#crontab -l -u username
Example
#crontab -l -u rahul
If you are a user and want to see your crontab you can just give (crontab -l)
Example3: Removing crontab for particular userThis can be achieved in two ways
1)removing all the crontab entries for a particular user
#crontab -r -l username
Example
#crontab -r -l rahul
2)removing one task for particular user,for doing this we have to edit the crontab
#crontab -e -l username