Scheduling important jobs with CRONTAB : Crontab Examples
Crontab is very important utility in Linux systems & is used to set up time based job scheduling. With the help of Crontab or cron, we can execute a command or a script to run at a particular time & we will discussing just that in this tutorial, with the help of some crontab examples.
For example , let’s say you created a script for taking backup & you need to run the script daily at 11:00 PM . For one or two systems, we can run the script manually, it might not be an issue but if we are having 10-20 systems or even more it will be a problem. So instead, we will use ‘crontab‘ to create an cron–job that will run the script automatically daily at 11:00PM.
(Recommended Read: How to replicate SELinux policies among Linux machines )
Now let’s see some commands & then we will discuss some Crontab examples,
• Add a new cron-job
To edit or create a cronjob , run
• Display all cron-jobs
• Removing a cron-job
Or we can also prompt a user before deleting an item by
Syntax for using Crontab
Examples of crontab
1- Running a backup script named bkp.sh located at /etc/script everynight at 11:00PM,
2- Running a weekly backup script named week.sh on every Friday at 11:30,
3- Running a monthly backup script named monthly.sh on 1st day of every month at 11:45PM,
4- Running backup script named weekday.sh on weekdays only at 11:59 PM
5- Running top command every 15 minutes to performance monitoring
Crontab is pretty easy to use and will make life of sysadmin much easier once you learn to make full use of it.
That’s it for now, we now end our tutorial on using CRONTAB, here we have discussed some crontab examples but there are plenty more use cases. If you have any queries/suggestions, feel free to use our comment box down below.