In this article, we are going to learn how to schedule cron job in the Linux platform step by step. Before scheduling a corn job you must know how it works.
A cron job is the same as a task scheduler in windows which executes a specific task at the scheduled time. This tutorial will help those peoples who are working on Linux platform like ORACLE Database Administrator
Crontab syntax and its operators
In the above picture, the first five fields accept date and time.
- * – This is an asterisk operator which means all allow.
- – – This hyphen operator allow you to specify the range, suppose you want to perform a task automatically on weekdays (Monday to Friday) so we set 1-5 in the day of week field.
- , – The comma operator allows us to define a list of repetition values like you want to execute a job at 1 am, 3 am, 5 am so we define in the cron 1,3,5.
- / – This is a slash operator which used in conjunction values, suppose you want to execute a job every 20 minutes then you can use the */20 in the minutes column.
Schedule cronjob every 5 minutes
Here is two way to schedule a cronjob every 5 minutes.
- In this option, we use the (,) operator. In this example, we make a list with comma separation.
0,5,10,15,20,25,30,35,40,45,50,55 * * * * your_script
2. This is a second option where we use the slash operator.
*/5 * * * * your_script