VMware Cloud Community
goody3335
Contributor
Contributor
Jump to solution

Scheduler - schedule for certain weekends of month

Hi Everyone,

I have a quick question about the scheduler.  There have been a few times that I've wanted to schedule things for a certain weekend of the month...for instance, schedule a reboot every third Sunday of the month.  I'm not sure if that's possible with the scheduler the way it's currently set up, but maybe I'm just completely over-looking something.  It seems to me like I have to manually input these dates.

Let me know if anyone has any ideas.

Thanks!

Tags (2)
1 Solution

Accepted Solutions
Andreas_Diemer
Enthusiast
Enthusiast
Jump to solution

Hi goody,

I only use the scheduler (from the left pane) if I want to schedule at fix times, e.g once a week, every hour nd so on.

For all other purposes I use self scheduling workflows. This means a workflow which is scheduling itself on runtime.

Just call your workflow in itself as a scheduled workflow. Before calling calc the scheduling date with your algorithm (e.g. every 3rd sunday).

After calling with this date you will get the scheduleTask. Here you can additionally set the boolean for restart in past.

Below the Workflow Goody3335 as schema:

goody3335-1.png

calc schedule could look like this for every 3rd Sunday

workflowScheduleDate = new Date(); //this is now
if (workflowScheduleDate.getMonth() < 11) {workflowScheduleDate.setMonth(workflowScheduleDate.getMonth() + 1);}
else {workflowScheduleDate.setMonth(0);}
workflowScheduleDate.setHours(12);
workflowScheduleDate.setMinutes(0);
workflowScheduleDate.setSeconds(0);
workflowScheduleDate.setDate(1);
if (workflowScheduleDate.getDay() > 0) {workflowScheduleDate.setDate(22 - workflowScheduleDate.getDay());}
else {workflowScheduleDate.setDate(15);}

You can run this workflow initially at anytime you want. Then it will reschedule itself to next month by adding a month or start over at 0.

setDate will set the schedule on the first day in this new month (now the date is the 1st of the claculated new month and time is set to 12:00 vCO local time = GMT+Offset)

From this we can calc the 3rd Sunday: 22-DayOfWeek is the 3rd Sunday, except Month starts on Sunday, the it is the 15th.

At the end scheduleDate ist 3rd Sunday in month 12:00

Regards, Andreas

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com

View solution in original post

7 Replies
tschoergez
Leadership
Leadership
Jump to solution

Hi!

AFAIK it's not possible to do such custom schedules 😞

Workaround: Schedule the task every week, and put some logic at the beginning of the workflow:

If today is third Sunday of month => continue, if not => just end

For some more elegant solutions you can extract the logic to a generic "wrapper" workflow to select the workflow to call when creating the task.

Some hints here: You can use an attribute of type "Properties" to fill the input-parameters for the inner workflow. And have a look at "Library / Orchestrator / Tasks": It's also possible to create / schedule Tasks programatically inside other workflows.

Regards,

Joerg

Andreas_Diemer
Enthusiast
Enthusiast
Jump to solution

Hi goody,

I only use the scheduler (from the left pane) if I want to schedule at fix times, e.g once a week, every hour nd so on.

For all other purposes I use self scheduling workflows. This means a workflow which is scheduling itself on runtime.

Just call your workflow in itself as a scheduled workflow. Before calling calc the scheduling date with your algorithm (e.g. every 3rd sunday).

After calling with this date you will get the scheduleTask. Here you can additionally set the boolean for restart in past.

Below the Workflow Goody3335 as schema:

goody3335-1.png

calc schedule could look like this for every 3rd Sunday

workflowScheduleDate = new Date(); //this is now
if (workflowScheduleDate.getMonth() < 11) {workflowScheduleDate.setMonth(workflowScheduleDate.getMonth() + 1);}
else {workflowScheduleDate.setMonth(0);}
workflowScheduleDate.setHours(12);
workflowScheduleDate.setMinutes(0);
workflowScheduleDate.setSeconds(0);
workflowScheduleDate.setDate(1);
if (workflowScheduleDate.getDay() > 0) {workflowScheduleDate.setDate(22 - workflowScheduleDate.getDay());}
else {workflowScheduleDate.setDate(15);}

You can run this workflow initially at anytime you want. Then it will reschedule itself to next month by adding a month or start over at 0.

setDate will set the schedule on the first day in this new month (now the date is the 1st of the claculated new month and time is set to 12:00 vCO local time = GMT+Offset)

From this we can calc the 3rd Sunday: 22-DayOfWeek is the 3rd Sunday, except Month starts on Sunday, the it is the 15th.

At the end scheduleDate ist 3rd Sunday in month 12:00

Regards, Andreas

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
goody3335
Contributor
Contributor
Jump to solution

Thank you both of the excellent ideas!  I really appreciate it.

Reply
0 Kudos
holashh
Enthusiast
Enthusiast
Jump to solution

Hi there,

I know this is answered but let me ask for extension of this: I need to plan reboot of VM each second Tuesday of month, I play with code above, but I get just first on it.

My code is the same as Andreas's but assume I need add one line to get possibility to differ which date is really 2nd tuesday.

Thanks in advance

Reply
0 Kudos
00rellana
Contributor
Contributor
Jump to solution

Hi holashh,

I am actually starting a vRO workflow to do just this ( monthly reboot of a VM ).

What vRO operation / action do you use to invoke the Reboot ?

I am fairly new to vRO and so far I have not found anything that calls a Reboot operation.

I checked all the categories in vRo under: generic, basi, Log, network, all workflows and All actions - to no avail.

Any tips you can provide will be greatly appreciated.

Regards,

OO

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

If you are just doing this monthly you can use the built in policies.  Just create a workflow you want to run and schedule it to run monthly.  There is a workflow under Library\vCenter\Virtual Machine Management\Power Management\Reboot Guest OS

Reply
0 Kudos
00rellana
Contributor
Contributor
Jump to solution

Hi qc4vmware,

BINGO! -- I found it.

I appreciate you sharing this information, now I can clone this workflow into my own workspace and test it.

Regards,

Oscar