How to schedule job on Ubuntu?
For scheduling job you should use Cron. It is a time-based job scheduler.
Crontab is a file where jobs are descirbed. You can edit this by calling command:
During first call you can be asked about default text editor. I chose VIM. Each line contains cron expression - the expression which describe frequency of command calling.
# ┌───────────── minute (0 - 59) # │ ┌───────────── hour (0 - 23) # │ │ ┌───────────── day of the month (1 - 31) # │ │ │ ┌───────────── month (1 - 12) # │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday; # │ │ │ │ │ 7 is also Sunday on some systems) # │ │ │ │ │ # │ │ │ │ │ # * * * * * <command to execute>
You can turn off temporarly some job by commenting it in crontab file or you can turn off cron service for turning off all jobs:
sudo service cron stop
If you want to call some shell script by cron, you have to add execute privilege to this script
chmod +x /path/to/script
- crontab guru: The quick and simple editor for cron schedule expression
- Cron Expression Generator & Explainer - Quartz
- Jessica Yung: Automate running a script using crontab
- Create a Cron Task in Ubuntu 16.04
- Wikipedia: Cron
- Stack Exchange: How to set a cron job to run a shell script?
- Stack Exchange: Command to ON/OFF cron job
Thank you for visiting my website. I hope you enjoyed content which I prepared and learned something valuable from it. If you want to be informed about my next entries or occasionally get a message with a collection of some interesting links, please subscribe to my newsletter. I will be extremely pleased if you do this and join my community!