How to skip saturday and sunday in a cron expression?

LinuxUnixCronQuartz Scheduler

Linux Problem Overview


Hi I want to create a cron expression excluding saturday and sunday.

Linux Solutions


Solution 1 - Linux

Begin the line with 0 0 * * 1,2,3,4,5 <user> <command>. The first fields are minutes and hours. In this case the command will run at midnight. The stars mean: for every day of the month, and for every month. The 1 to 5 specify the days. monday to friday. 6=saturday 0=sunday.

Solution 2 - Linux

Try this:

# run every two hours at the top of the hour Monday through Friday
0 */2 * * mon-fri <command>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRakesh SabbaniView Question on Stackoverflow
Solution 1 - LinuxMichelView Answer on Stackoverflow
Solution 2 - LinuxSiegeXView Answer on Stackoverflow