How to run a Cron job weekly?

Better Stack Team
Updated on October 5, 2023

To run a cron job weekly, you can use the following format in your crontab file:

 
0 0 * * 0 /path/to/command

This cron job will run at midnight (0 hour and 0 minute) on Sunday (day 0). Replace /path/to/command with the command you want to run.

🔭 Want to get alerted when your Cron doesn’t run correctly?

Go to Better Stack and start monitoring in 5 minutes.

Here's a breakdown of the format:

  • The first 0 represents the minute (0-59)
  • The second 0 represents the hour (0-23)
  • The *s**** in the third and fourth positions represent the day of the month and the month (respectively). Using * means**** the job will run every day of the month and every month.
  • The 0 in the fifth position represents the day of the week, with 0 representing Sunday, 1 representing Monday, and so on.
  • The final field is the command to be executed.

So the cron job in the above format will run every Sunday at midnight.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github