Cron is one of the handy and powerful tools in Linux OS mostly used by the system administrators. Cron jobs let users run a particular task (command or a script) repeatedly at a given date and time. The cron job once set automatically run at that particular date and time without user involvement. Some of the tasks that can be handled by cron include backups of log files and database, maintenance tasks, sending emails, monitoring system status, etc. The crond is the service that runs in the background and regularly checks the /etc/crontab file, /var/spool/cron, and /etc/cron.d directories for the scheduled jobs. If the scheduled time for the cron jobs matches the OS time, the jobs are executed.
This post describes how to run a cron job every Monday and Thursday.
The syntax of a crontab entry is as follows:
Each * in this syntax refers to the following:
An asterisk (*) represents all allowed values. For instance, an asterisk in the Hour field will run the cron job every hour.
Run a Crontab Monday and Thursday
To run a cron job every Monday and Thursday, edit the crontab file using the command below:
Then add an entry for the cron job. For instance, to run a cron job every Monday and Thursday at 5:00 am, the entry would be:
If you want to run the cron job every Monday and Thursday at 5:00 pm, the entry would be:
Save and close the file.
Now, your scheduled job will run on every Monday and Thursday at specified time. However, remember that the job will not be executed if your system is down at the scheduled time.
In this post, we covered how to run a cron job every Monday and Thursday in a Linux OS. Similarly, you can schedule any task on any specific day and time using the cron jobs.