Evgeny Shvarov · Dec 19, 2020 1m read

Schedule tasks with one line using iris-cron-task

Hi, folks!

Sometimes I need to schedule a task programmatically.

And in 99% I need having some class method be periodically called.

And I want to have the schedule be started by one line. As a job in crontab.

I decided to introduce such a module with iris-cron-task module.

See the details below!

Install the module with:

USER>zpm "install iris-cron-task"

And then you'll be able to schedule tasks with one line. 

E.g. if I want the following command

set ^A($I(^A))=$H

be started every minute I can call the following:

zw ##class(dc.cron.task).Start("Task name","* * * * *","set ^A($I(^A))=$H",1,.taskid)

this will create a task with taskid which will run every minute.

When you don't need the task any more you can delete it with:

zw ##class(dc.cron.task).Kill(taskid)

I supported only a few cron settings, like every minute:

* * * * *

Every hour:

0 * * * *

And every day in a certain hour:

0 0 * * *

You could find useful the cronmaker site to get the cron expression for any schedule you need.

Thanks to @Lorenzo Scalese for introducing support for an arbitrary cron expression. 

PR are welcome if you need more!

Hope you like it, any feedback is appreciated!

1 1 8 155
Log in or sign up to continue


That's really cool. I had a need for exactly this functionality a while back but had to find a different solution. I wish I had this then.

Thanks, Nigel! Yes, my motivation to publish it was laziness) It's annoying to create a yet-another-class or method just to have something perpetually running )

The support for arbitrary cron expression is introduced with the 1.1.1 release.

The support of any cron expression is introduced by @Lorenzo Scalese, thank you!

Very good! 

I translated your article into Portuguese laugh

Obrigado, Larissa! I appreciate!

No, the USER Namespace still USER Namespace in a Portuguese installation. 

PS: article fixed