Technology

#How to Run a Cron Job Only on Sunday (or Any Other Day) – CloudSavvy IT

“#How to Run a Cron Job Only on Sunday (or Any Other Day) – CloudSavvy IT”

Bash Shell

I needed to setup a cron job to perform some maintenance which I wanted to automatically run on Sunday night since that’s usually a low traffic period. After looking up the right syntax in the manual for the eleventy-hundredth time, I realized I hadn’t written anything in a while, and I should probably jot this one down for later.

The normal syntax for a cron job item is usually right there in the editor window in a nearly unreadable dark blue font, but after using vim’s set background=dark option, turns into a nice light blue.

Based on that last line, the syntax is…

<minute> <hour> <day of month> <month> <day of week> <command>

And that means a cron job line that runs every Monday at 1:05 AM would then be structured like this:

5 1 * * 1 /the/command/goes/here

That “dow” option stands for “day of week” and is a number from 0 to 7, with the week starting and ending on Sunday. So here’s the listing:

  • 0 – Sunday
  • 1 – Monday
  • 2 – Tuesday
  • 3 – Wednesday
  • 4 – Thursday
  • 5 – Friday
  • 6 – Saturday
  • 7 – Sunday

Bottom line, if you want something to run on Sunday you can either use 0 or 7 in the “dow” column.

If you liked the article, do not forget to share it with your friends. Follow us on Google News too, click on the star and choose us from your favorites.

For forums sites go to Forum.BuradaBiliyorum.Com

If you want to read more like this article, you can visit our Technology category.

Source

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close

Please allow ads on our site

Please consider supporting us by disabling your ad blocker!