I need to schedule a job to run on the 25th of each month. If the 25th falls on a weekend I need the job scheduled on last Friday before the 25th. The Windows Task Scheduler doesn't have an option for this kind of task. Can anybody tell me what I should do?
Poisonbit's answer is basically correct. If the scheduling functions built-in to the Windows task scheduler can't provide the type of specific schedule you need, you'll need to work around the limitations yourself. His suggestion is to execute your job from a script that the task scheduler will run on a simple daily schedule. But the script will be smart enough to only execute the "real" job on the proper day. I've taken the liberty of providing a PowerShell based sample you could use.
All it does it check the current date. If it's the 25th and not Saturday/Sunday or if it's Friday and the 23rd or 24th, it will print the "time to execute my job" message which you would replace with the command to actually execute your job.
*Updated with better logic thanks to Paul
A wrapper that evaluates such conditions.
If you know shell scripting, you can make it using gnu date.
If you know Perl, try Time::Piece (in core since Perl 5.009).
Then call the wrapper from cron.daily, calculate a date is a light daily task for a machine.
Ryan Bolger has got it for the Friday condition...
If the 25th falls on a Monday through Thursday though, you'll still want to run the program on the 25th, so change his conditional to
Note: I've never done PowerShell scripting, I'm just guessing on syntax from the code Ryan provided.