====== Cron ====== **cron** is basically a job scheduler that can help automate many conventional but repeatedly used functionality. Cron works using the crontab file. It is a file that lists all the scheduled jobs and when to perform them. On a standard Linux machine, there are different crontab files based on user privileges. We’ll mostly base our examples on the default users’ crontab. crontab is the command that allows us to modify crontab files and cron executes them. The jobs inside the crontab file are known as cron jobs, and consist of standard Linux commands. They also contain the time-period when cron needs to execute them. ┌───────────── 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) │ │ │ │ │ │ │ │ │ │ * * * * * {{:ubuntu:crontab-structure.jpg?800|}} ---- [[Ubuntu:Cron:Delete Crontab|Delete Crontab]] [[Ubuntu:Cron:Deny Crontab Access to Specified Users|Deny Crontab Access to Specified Users]] [[Ubuntu:Cron:Edit Crontab|Edit Crontab]] [[Ubuntu:Cron:Limit Crontab Access to Specified Users|Limit Crontab Access to Specified Users]] [[Ubuntu:Cron:List Crontab|List Crontab]] [[Ubuntu:Cron:Send Cron Results to Specified Email Account|Send Cron Results to Specified Email Account]] [[Ubuntu:Cron:Set crontab editor to vim|Set crontab editor to vim]] [[Ubuntu:Cron:Verify Crontab File|Verify Crontab File]] ---- ====== Useful Examples ====== [[Ubuntu:Cron:Create a Backup of All User Accounts at 5 am Daily|Create a Backup of All User Accounts at 5 am Daily]] [[Ubuntu:Cron:Create a Backup of All User Accounts at 5 am Per Week|Create a Backup of All User Accounts at 5 am Per Week]] [[Ubuntu:Cron:Schedule Cron to Execute a Job Twice a Day|Schedule Cron to Execute a Job Twice a Day]] [[Ubuntu:Cron:Schedule Cron to Execute a Job at 2 am Daily|Schedule Cron to Execute a Job at 2 am Daily]] [[Ubuntu:Cron:Schedule Cron to Execute a Job at 3:15 am Daily|Schedule Cron to Execute a Job at 3:15 am Daily]] [[Ubuntu:Cron:Schedule Cron to Execute a Job at 8 pm Every Week|Schedule Cron to Execute a Job at 8 pm Every Week]] [[Ubuntu:Cron:Schedule Cron to Execute a Job at 8 pm on Monday|Schedule Cron to Execute a Job at 8 pm on Monday]] [[Ubuntu:Cron:Schedule a Cron Job at 8 pm on Monday, and Saturday|Schedule a Cron Job at 8 pm on Monday, and Saturday]] [[Ubuntu:Cron:Schedule a Cron Job to Run on Every Minutes|Schedule a Cron Job to Run on Every Minutes]] [[Ubuntu:Cron:Schedule a Cron Job to Run on Every 10 Minutes|Schedule a Cron Job to Run on Every 10 Minutes]] [[Ubuntu:Cron:Schedule a Cron Job to Run on Every 15 Minutes on Sunday and Monday|Schedule a Cron Job to Run on Every 15 Minutes on Sunday and Monday]] [[Ubuntu:Cron:Schedule a Cron Job to Run on Specified Months|Schedule a Cron Job to Run on Specified Months]] [[Ubuntu:Cron:Schedule a Cron Job to Run on 15 January at 8 PM|Schedule a Cron Job to Run on 15 January at 8 PM]] [[Ubuntu:Cron:Schedule a Cron Job to Run in Every Second Month|Schedule a Cron Job to Run in Every Second Month]] [[Ubuntu:Cron:Schedule a Cron Job to Run on the First Sunday of Each Month|Schedule a Cron Job to Run on the First Sunday of Each Month]] [[Ubuntu:Cron:Schedule a Cron Job to Run on Every Three Hours|Schedule a Cron Job to Run on Every Three Hours]] [[Ubuntu:Cron:Schedule a Cron Job to Execute Twice on Every Saturday and Monday|Schedule a Cron Job to Execute Twice on Every Saturday and Monday]] [[Ubuntu:Cron:Schedule a Cron Job to Run on Every 30 Seconds|Schedule a Cron Job to Run on Every 30 Seconds]] [[Ubuntu:Cron:Schedule Multiple Jobs in a Single Crontab Entry|Schedule Multiple Jobs in a Single Crontab Entry]] [[Ubuntu:Cron:Schedule Yearly Cron Jobs|Schedule Yearly Cron Jobs]] [[Ubuntu:Cron:Schedule Monthly Cron Jobs|Schedule Monthly Cron Jobs]] [[Ubuntu:Cron:Schedule Weekly Cron Jobs|Schedule Weekly Cron Jobs]] [[Ubuntu:Cron:Schedule Daily Cron Jobs|Schedule Daily Cron Jobs]] [[Ubuntu:Cron:Schedule Hourly Cron Jobs|Schedule Hourly Cron Jobs]] [[Ubuntu:Cron:Schedule a Cron Job on System Reboot|Schedule a Cron Job on System Reboot]]