Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


jsmisek
2015-11-17T14:09:46Z
We need to run a job on the first thursday following the first monday. Hope that makes sense. Basically if thursday comes before the first monday it should be ignored. If it follows the first monday it should run on that Thursday. Any ideas?
Sponsor
Forum information
thomas
2015-11-17T15:52:26Z
Don't create a trigger. Schedule a job that runs once day. Create some .NET logic that returns true or false depending on wether your requirements are met or not. Use a condition to determine if the rest of job should run.

Thomas
jsmisek
2015-11-17T17:46:53Z
For posterity's sake i was hoping to stay within vcron's ability. But it won't be hard to write a quick script to take care of this.

Thanks again.
ErikC
2015-11-17T19:45:46Z
Hi,

At the moment I'm not behind a Visualcron client, but I think you can do this by having two triggers, on for the Thursday and one for Monday.
Using user variables and conditions I believe you should be able to do this.

I'll try to solve this issue tomorrow.

Regards
Erik
Uses Visualcron since 2006.
Support
2015-11-18T07:44:14Z
Two interval Triggers is the best solution.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
ErikC
2015-11-18T10:47:15Z
Hi,

I tried it today to solve this with the use of user variables. I came far, but It was to complex to continue.
So I ended up with one .NET task doing the logic and one condition.
You also have to have two triggers, one for the 1st Thursday (specific day of the month) and every Monday.

The .NET task (1st task in job) is a c# task with this code:

using System;
public class Test
{
  public static bool mayRun()
  {
    if (DateTime.Today.DayOfWeek == DayOfWeek.Thursday && DateTime.Today.Day <= 7)
    {
      //1st Thursday of the week
      return true;	
    }
    else if (DateTime.Today.DayOfWeek == DayOfWeek.Monday && (DateTime.Today.AddDays(-4).Month == DateTime.Today.Month) && DateTime.Today.Day <= 11)
    { 
      //1st Monday after the 1st Thursday
      return true;
    }
    return false;
  }
}


This code gives return value: True if it's the 1st Thurday of the month or the 1st Monday after the 1st Thursday of the month.
Using a condition you set on you 2nd task in your job, you check if the output of the .NET task is True.
If the condition matches you continue else you exit the job.
The next tasks in your job do not need the condition anymore.

Regards
Erik
Uses Visualcron since 2006.
Scroll to Top