- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to run a crontab job every week on Sunday?
In order to create a crontab job to run every Sunday, we first need to explore and understand what a crontab job is.
A crontab is nothing but a list of commands that we can run during a cron job. A cron job is a utility that schedules automatic execution of commands at specific times.
We can start a cron job with the help of bash script by following the commands shown below −
crontab -e
This will open a file which you can edit, insert the cron job shell script in the above file and then close that file.
Just insert the code shown below in the above file
* * * * * sample.sh
The above command contains 5 *, where each * indicates the time and then follows the stars. We have the script which we want to run as a cron job. In the sample.sh we need to write the following command to make the environment variables available to it.
Now we understand how we can create a crontab job, it is time to understand what these * actually mean and how we can replace their values to solve our particular question.
The five * in the above command actually has a separate meaning attached to them. These mainly mean −
Seconds: 0-59 Minutes: 0-59 Hours: 0-23 Day of Month: 1-31 Months: 0-11 Day of Week: 0-6
If we want to run a crontab job every sunday then we have three possible combinations that we can run. These are −
5 8 * * 0 5 8 * * 7 5 8 * * Sun
The 5 8 in the above crontab job command stands for the time of the day when this will happen: 8:05.
It should be noted that we need to append our script that we need to run after any of the above commands we choose.
The final command should look something like this −
5 8 * * 0 script.sh
- Related Articles
- How to Run a Cron Job Every Day on a Linux System
- How to test a weekly crontab job on Linux?
- How would I get a cron job to run every 30 minutes on Linux?
- Crontab day of the week syntax on Linux
- How to Create a crontab Through a Script on Linux
- How to use Boto3 library in Python to run a Glue Job?
- The ratio of the sale of eggs on Sunday to that of the whole week is 3:7. If the total sale of eggs on Sunday was 36, find the total sale of eggs during the whole week.
- How to run a method every 10 seconds in Android?
- How to run a method every 10 seconds in Android using Kotlin?
- Specify an Editor for Crontab on Linux
- How to run Gunicorn on Docker?
- How to run Linux libraries on Docker on Windows?
- How to query MySQL on the current week?
- Run Cron Job Only If It Isn’t Already Running in Linux
- How to run Python code on Google Colaboratory?
