2

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.

1
  • Can't you check if it's the first of a month in the daily script/program.
    – TobiMarg
    Jan 16, 2014 at 12:28

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .