Run task every weekday but don't on national holiday

0

Is there any out of the box solution in Windows Task scheduler to run task every weekday but skip it if it's national holiday like Christmas or, even better, Easter?

If not out of the box then script?

hoggar

Posted 2018-11-12T13:00:58.277

Reputation: 143

1Not out of the box. But the question is, does the computer run if its a national holiday? You can just make it so that the task is not executed if missed, so that if the computer is turned off, the task is simply not run. – LPChip – 2018-11-12T13:03:02.340

1This is really just a trivial type task.... You schedule the process to run every workday as usual, but you put control at the script level to say first check if the day equals some YYYY-MM-DD, etc. string within a file or some hard-coded logic at the first part of the execution and if it is equal to one of those days, to then not run and end. You could probably do some quick research and get the YYYY-MM-DD of the national holidays for the next 10 year, put it in a list a script will check or some script logic accordingly—maybe 15 minutes tops work and research to control at the front-end. – Pimp Juice IT – 2018-11-12T15:17:07.583

@PimpJuiceIT although this is also what I had in mind, if the pc is turned off anyways at holidays, it is much easier to just ensure that the task won't run it if were missed. That way you have full control on when the script runs or not. – LPChip – 2018-11-12T15:29:59.433

@LPChip I agree with that strategy I suppose assuming the machine is powered off but I personally will not typically power off a critical machine that is expected to be up 24x7. Perhaps this particular job is just one of many and the machine must be running to ensure those jobs are run which do occur on the holidays this other process does not. Furthermore, in the event someone or process does forget to power off the machine on the particular date, then that means the process would run I suppose. I agree though, many ways to skin this cat depending on various factors and such!!! – Pimp Juice IT – 2018-11-12T15:53:40.187

For "extra extra read all about it" control, you could implement both solutions in one.....Running like a train, chugga, chugga, choo choo!!! – Pimp Juice IT – 2018-11-12T15:56:12.470

This is server and it is working 24/7. The option with national holidays DB is of course possible but I was looking for maintenance free solution because of few holidays that are on the different days every year, as I mentioned example of the Easter. I though maybe there is some way to automatically look for national holidays based on OS regional settings. For example after quick search I only found holidays till 2021. – hoggar – 2018-11-12T16:11:07.437

1

You probably need to check a source for the holidays regardless whether an API third party solution or a list you make that covers the next 10, 20, etc. year. https://stackoverflow.com/questions/18996577/how-to-get-national-holidays-of-selected-country, https://www.programmableweb.com/category/holidays/api, etc.

– Pimp Juice IT – 2018-11-18T17:34:16.847

No answers