Schedule tasks with one line using iris-cron-task
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
be started every minute I can call the following:
zw ##class(dc.cron.task).Start("* * * * *","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:
I supported only a few cron settings, like every minute:
* * * * *
0 * * * *
And every day in a certain hour:
0 0 * * *
PR are welcome if you need more!
Hope you like it, any feedback is appreciated!