Announcement - Changes coming to Cron jobs

So let me end the suspense, obviously ST doesn’t conform to linux standards, so 2 things to note when using Day of Week

  1. It has to be between 1 and 7 (Sun to Sat), it does not accept 0
  2. When using Day of Week, the Day of Month needs to be ? and vice versa

So there’s how you generate a Random Day of week and Random hour between 10am and 6pm

def random = new Random()
Integer randomHour = random.nextInt(18-10) + 10 // 10am to 6pm
Integer randomDayOfWeek = random.nextInt(7-1) + 1 // 1 to 7
schedule("0 0 " + randomHour + " ? * " + randomDayOfWeek, handler)

@Jim, you may want to clarify the docs w.r.t. Day of Week and Day of Month selection and acceptable values

1 Like