Scheduling important jobs with CRONTAB
Hello Linux-addicts, in this tutorial we will learn to use an important Linux utility named ‘Crontab’. With the help of Crontab or cron, we can execute a command or a script to run at a particular time.
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.
Now let’s see some commands & then we will discuss some examples of crontab
• 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. If you have any queries/suggestions, feel free to use our comment box down below.