Hi I want to create a cron expression excluding saturday and sunday.
You could use a second cron job at 09pm to start a second program that tells the first program to terminate. There are a number of ways to do this. One of the easiest might be to have the second program touch terminate. txt in a convenient place.
You can stop a single cron job by removing its line from the crontab file. To do that, run the crontab -e command and then delete the line for the specific task. Alternatively, you can stop the cron job by commenting it out in the crontab file.
0 * * * * -this means the cron will run always when the minutes are 0 (so hourly) 0 1 * * * - this means the cron will run always at 1 o'clock. * 1 * * * - this means the cron will run each minute when the hour is 1.
The quickest way would be to edit the crontab file (which can be done by typing crontab -e ) and simply comment the job you want disabled. Comment lines in crontab start with a # . For others wondering, the command crontab -e will open the text editor for the current users crontab file.
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.
Try this:
# run every two hours at the top of the hour Monday through Friday 0 */2 * * mon-fri <command>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With