7 Replies Latest reply on Jun 25, 2019 2:51 PM by 00rellana

    Scheduler - schedule for certain weekends of month

    goody3335 Enthusiast

      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!

        • 1. Re: Scheduler - schedule for certain weekends of month
          tschoergez Master
          VMware EmployeesvExpertUser Moderators

          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

          1 person found this helpful
          • 2. Re: Scheduler - schedule for certain weekends of month
            Andreas Diemer Hot Shot

            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

            1 person found this helpful
            • 3. Re: Scheduler - schedule for certain weekends of month
              goody3335 Enthusiast

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

              • 4. Re: Scheduler - schedule for certain weekends of month
                holashh Enthusiast

                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

                • 5. Re: Scheduler - schedule for certain weekends of month
                  00rellana Lurker

                  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

                  • 6. Re: Scheduler - schedule for certain weekends of month
                    qc4vmware Expert

                    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

                    • 7. Re: Scheduler - schedule for certain weekends of month
                      00rellana Lurker

                      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