How to schedule a task to run every weekday except on the 1st day of the month

1

1

How to schedule a task to run every weekday except on the 1st day of the month?

To avoid the XY problem: I'm building a backup system that makes backups on the 1st of every month and daily backups every weekday. I have three tasks running three programs:

  1. Monthly backup - 1st of every month
  2. Daily backup - mon-fri
  3. Clear old backups - every day

I keep X monthly backups and Y daily backups. If the 1st happens on a weekday, I get two backups very close to each other and I want to avoid the hard drive cost

Win 7, Win server 2008 and Win server 2012 platforms.

Nenotlep

Posted 2014-01-16T11:16:04.820

Reputation: 183

Can't you check if it's the first of a month in the daily script/program. – TobiMarg – 2014-01-16T12:28:27.117

Answers

1

Get your scheduled task to run a batch script. In there, you can put

SET DATE=%DATE%
SET DAY=%DATE:0,2%

This will set the environment variable DAY to the first two characters of the date, which (on my system) comes as dd/mm/yyyy. (Obviously check this first using echo %DATE%.)

Then you can exit the script if DAY is equal to 01, and run your backup program if it's not.

benshepherd

Posted 2014-01-16T11:16:04.820

Reputation: 1 448