Professional Documents
Culture Documents
Beginners
Posted by Prince DAN December 28, 2019 in DevOps
Crontab is an important utility that is used for scheduling cron jobs i.e. setting up a specified
time-based job. Cron job can be a single command or we can also schedule cron to run bash
scripts.
These cron jobs help us automate repetitive tasks like backups, system updation, or running
some specific command or scripts, etc. We can schedule cron jobs & the system will then
execute the mentioned commands or scripts without human intervention. Cron jobs can be
scheduled to run on the minute, hour, day of the month, month, day of the week basis. We can
also combine any of these to schedule cron jobs.
Also Read: How to setup SSH login without password on Linux systems
(minute) (hour) (day of the month) (month) (day of the week) (command/script path)
* * * * * command, script(s)
-----
|||||
$ crontab –e
$ crontab –l
$ crontab –r
Or we can just edit out a job that we don’t want need with ‘crontab -e’ command.
$ crontab -u test_user -e
$ crontab -u test_user -l
$ crontab -u test_user -r
Here, you can replace ‘test_user’ with the username you need to see access cron jobs for. The
root user will access to cron jobs for all users by default.
00 22 * * * /etc/test_user/backup.sh
30 23 * * 5 /etc/test_user/weekly_backup.sh
45 11 30 * * /etc/test_user/monthly_backup.sh
59 11 * * *1-5 /etc/test_user/weekday_backup.sh
or
59 11 * * *1 2 3 4 5 /etc/test_user/weekday_backup.sh
59 11 * * *1 3 5 7 /etc/test_user/weekday_backup.sh
* /10 * * * command
These were only some examples of how you can use cron jobs, there are plenty more
combinations we can use. We now end our tutorial on scheduling cron jobs on the Linux
system. Please feel free to send in any questions or queries you have using the comment box
below.
If you think we have helped you or just want to support us, please consider these:-
TheLinuxGURUS.com