How to write a key date that won't work Except for 3rd week, Sunday, 4th week on Monday of the month

eg. schellscript will not run on April 18th, 19th and 20th, and then for May 16th, 17th and 18th, etc.

0


a source to share


2 answers


You can get the working day in numeric form from the date command with date "+%w"

. The output will be 0 for Sunday, 1 for Monday, etc.

You can get the day of the month using date "+%d"

. Subtract one of these and divide by 7; which will give you how many complete weeks there were in the current month.



From there, it's just a simple if / then command. If you need more help actually implementing this, just ask.

Hope it helps!

0


a source


I would suggest using cron for this sort of thing, to decouple the scheduled execution from what the script actually does .



Take a look here on how to use cron.

0


a source







All Articles