I'm looking to create a schedule to run the 2nd Wednesday of every month. I've tried a couple of variations, and cannot seem to find anything that works. My plan is to have my new patch label deploy to my test lab automatically each month instead of having to change the date to match. Since "Patch Tuesday" never really falls on the same date I was hoping to do this through cron.

I'm testing this today using the 1rst Tuesday of the month. I found a site http://www.cronmaker.com/ that I used to generate this 0 0 8 ? 1/1 TUE#1 *. Which seems to have more fields than needed, and Kace also does not see it as valid. I also plugged it into http://www.dataphyx.com/cronsandbox/ and it saw it as invalid.

I also tried 0 8 1,2,3,4,5,6,7 * 2 which I would have thought would have worked, but it's returning Wed, Thur, Fri dates even though the last digit is set to 2. It's also returning 6/18 & 6/25 which are not in the first seven days of the month.

Can someone who actually knows cron help me out? 

Answer Summary:
It's my understanding that the classic cron format is used and it doesn't have the ability to run a schedule one day (Tuesday) per month. Something like this should have it run every other Tuesday: * 0,1,2,3,4,18,19,20,21,22,23 * * 2/2 Supported functions can be seen on p.210 in the 5.4 admin guide, although the first Monday example is apparently wrong: https://www.kace.com/support/resources/~/media/Files/Support/Documentation/K1000/v54/K1000-Admin-Guide-v54.ashx
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

3

Here is a powerpoint deck from the 2009 Konference that has a cron explanation on p.10:  http://www.kace.com/~/media/Files/Support/KACE-Konference/2009/KBOX-Power-Management.ashx

Answered 06/04/2013 by: jknox
Red Belt

  • Maybe it's just the site I'm checking them on? I pasted 15 0,1,2,3,4,18,19,20,21,22,23 * * 2 (slightly modified from the slide) into http://www.dataphyx.com/cronsandbox/. It sees the hours/days as it should.

    Tue 2013-Jun-04 2115
    Tue 2013-Jun-04 2215
    Tue 2013-Jun-04 2315
    Tue 2013-Jun-11 0015
    Tue 2013-Jun-11 0115

    When I change it to 0 8 1,2,3,4,5,6,7 * 2 which from what I understand should get every Tues that falls on the 1,2,3,4,5,6, or 7th day of the month. I get these results. It's almost like it's not paying attention to that last field.

    Wed 2013-Jun-05 0800
    Thu 2013-Jun-06 0800
    Fri 2013-Jun-07 0800
    Tue 2013-Jun-11 0800
    Tue 2013-Jun-18 0800
    Tue 2013-Jun-25 0800
    • It's my understanding that the classic cron format is used and it doesn't have the ability to run a schedule one day (Tuesday) per month.

      Something like this should have it run every other Tuesday:

      * 0,1,2,3,4,18,19,20,21,22,23 * * 2/2

      Supported functions can be seen on p.210 in the 5.4 admin guide, although the first Monday example is apparently wrong: https://www.kace.com/support/resources/~/media/Files/Support/Documentation/K1000/v54/K1000-Admin-Guide-v54.ashx
      • Just curious on how the Monday example is wrong? That was what I was trying to do, but it looks a lot cleaner. Is it a bug?

        I ended up using this:
        30 9 1,2,3,4,5,6,7 * 2

        which did do a detect at 9:30 today. I guess I'll keep an eye on it to see if/when it runs again.
  • Would Kace support provide me this info, or would they charge? I can test this be entering it into the Kbox, and verifies it runs on the time/day specified. My only problem is that I wouldn't want it running every Wed-Fri as well. I wouldn't really know without watching it everyday over the next month.
    • Dugullett, were you ever able to get a solid answer of how to get a patching job cron syntax to run only on the 2nd Wednesday of every month (for example)? I asked support and all they could do was point me to this post, not much help.
      • Yeah.... support has actually referenced my own posts before. I actually gave up, and I run them weekly. Our techs were pulling machines off of the shelf that had been sitting for months without a fresh image. If I were to do it only once a month those machines would more than likely never get patched. We have five main types of machines. I patch one group Monday, the 2nd Tuesday, and so on.
      • This content is currently hidden from public view.
        Reason: Removed by member request
        For more information, visit our FAQ's.
  • This content is currently hidden from public view.
    Reason: Removed by member request
    For more information, visit our FAQ's.
Please log in to comment

Answers

1

So here is how I have solved this patch scheduling issue for my environment. You can use Help Desk Ticket rules to modify anything in the Kbox database.

Disclaimer: You would want to be very careful and probably test this in a test environment because you could accidently cause major problems with your database. Currrently I'm running this in 5.3.53053 and I haven't fully tested this in the 5.4SP1 release.

First in your Patch Schedule set the "Run on the" setting. It doesn't matter what date you set here but make sure to put in every month and the time you want the patch to run.

You would want to create a custom ticket rule that runs Monthly and set the Next run date to the first of the month. It's very important that this runs on the 1st of every month to make this rule work. In the Select Query Section put this in:

select distinct IM_CRON.days_of_month, IM_CRON.ID,  PATCHLINK_SCHEDULE.DESCRIPTION, PATCHLINK_SCHEDULE.IM_CRON_ID
FROM IM_CRON, PATCHLINK_SCHEDULE
where PATCHLINK_SCHEDULE.DESCRIPTION
= 'PatchSchedule' and IM_CRON.ID = PATCHLINK_SCHEDULE.IM_CRON_ID;


Note: Replace PatchSchedule with a the name of your Patch Schedule.

Next click the check box for Run an update query, using the results from the one above

Now put this in for the Update Query:

update  IM_CRON set DAYS_OF_MONTH=if(dayofweek(curdate())<5,12-dayofweek(curdate()),19-dayofweek(curdate())) where IM_CRON.ID in (<TICKET_IDS>);


Now just save it and this should change your patch schedule every month to the second Wednesday.

Informational note for some reason the Kron numbers for the days of the week is 0-6 where 0 starts on Saturday in the Kbox. I believe Kron is supposed to start on Sunday for 0 but the Kbox works differently from my testing.


Also if you are wanting to run your microsoft patches the wednesday after patch tuesday this schedule won't work all the time because in some months the second wednesday occurs before the second tuesday.

Answered 06/04/2013 by: darkhawktman
Green Belt

  • That's good info. Unfortunately I don't use the service desk piece with the Kbox, but have thought about setting it up to allow some ticket rules to make my life easier. Just trying to find the time.

    Our patching process currently (not using Kace) is very manual. We go monthly, and select each patch. Then create a baseline, and a deployment schedule for that baseline. I guess worst case I just go in every month, and change the deployment date. That's only one step instead of the 15 I currently do.
  • From dugllett:
    "When I change it to 0 8 1,2,3,4,5,6,7 * 2 which from what I understand should get every Tues that falls on the 1,2,3,4,5,6, or 7th day of the month. I get these results. It's almost like it's not paying attention to that last field.

    Wed 2013-Jun-05 0800
    Thu 2013-Jun-06 0800
    Fri 2013-Jun-07 0800
    Tue 2013-Jun-11 0800
    Tue 2013-Jun-18 0800
    Tue 2013-Jun-25 0800
    "

    I don't think the Date and Day values are AND'ed. The results from dataphyx/cronsandbox/ show an OR, i.e. cronjob runs if date is 1,2,3,4,5,6,7 OR a Tuesday.

    Good luck.
Please log in to comment
This content is currently hidden from public view.
Reason: Member is not approved yet
For more information, visit our FAQ's.

Answer this question or Comment on this question for clarity

Share