How to run a Cron job weekly?

Better Stack Team
Updated on May 26, 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.

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.

Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →

Reliability is the
ultimate feature

Delightful observability tools that turn your logs & monitoring into a secret weapon for shipping better software faster.

Explore Better Stack