I’m working on scheduling a task to run every 15 minutes. This isn’t a problem with @every 15m. But the first task waits 15 minutes. Can I execute it right away? Or do I have to execute one separately?
You are correct if you start your workflow exec with a cron schedule the first execution is going to be created and started right away but your workflow code exec won’t start till the cron timer fires.
One way you could do this is:
Start your wf execution without setting cron, have workflow function take for example some boolean “isfirst” param, set it to true
Before your workflow completes check isFirst flag, if true start async child workflow (of the same workflow type) with abandoned parent close policy (see here for more info on that) and set the CronSchedule in ChildWorkflowOptions. Also pass false as isFirst so wf code will bypass starting the child workflow again.
This way you would have an execution right away and then again according to the set CronSchedule in ChildWorkflowOptions.