Run in every 2 seconds


sure. thank you. :slight_smile:

though in this case the code is a few lines, likelihood of failing is pretty low and no error in the logs.


You should try schedule() and give it a cron string.


will do ... does schedule work in drivers?

think i had tried this first ... which didnt seem to work.

schedule("0/2 0 0 ? * * *", method)

thank you.



I need to do something similar. Did you ever make this work?


i still use runIn in the driver … havent checked if schedule works now.

schedule works fine in apps though.


Yes, schedule works fine in drivers. assuming you create your cron schedule correctly :wink:

For the above example,, it will run every 2 seconds from 12:00am to 12:01 am

0/2 0 0 ? * * *
XXX                  Every 2 seconds
    X                during minute zero
      X              during hour zero
        X            any day of the month
          X          every month
            X        every day of the week
              X      every year

Run every 2 seconds forever:

schedule("0/2 * * * * ? *", method)


was that fixed after may 27th? because as of may 27th the day i posted the above … schedule wasnt scheduling anything from a driver.


No, there were no changes to that method since launch. As I mentioned, the cron expression you had only ran for 1 minute at midnight,, is that what you were expecting?


ok. correct.


I tried after this post. I did not seem to get any effect at all from it.


You tried what? can you post the schedule command you tried?


After looking at your example closer my cron string was off. I used a website to generate it for me. I just tried again. My job seems to be happily firing right on time.


Great! The thing to keep in mind is that a standard cron expression only goes as low as minutes, ours has seconds as well so there is an extra parameter at the beginning. The quartz reference I posted above is the correct one.


inserted this code, saved then saved the app settings:

schedule("0/2 * * * * ? *", method)

def method()	{
    log.debug "this worked"

dang it i copied the cron you provided. let me try the original to make sure it works right.

EDIT: yeah the original schedules fine:

o well … at least its working right now. :slight_smile:



btw … heres the website i use for cron generator for quartz:



Is there anywhere that we can see the upcoming scheduled events for drivers like we can for apps?


No there is not, but I just put in a ticket to add it! :slight_smile:


@chuck.schwer has this been added somewhere?


Yes, this was added in 1.1.5, you will see it at the bottom of the device details page.


You said this was every 2 seconds forever. So would

schedule("0/30 * * * * ? *", method)

be every 30 seconds forever? And you cancel it by calling the unschedule(method) function, correct?