Schedule() not accepting cron string

Hi there, I have a custom application where I'm trying to schedule a function sendNotification() to run every Friday at 10 PM for which I'm using the following cron string "0 0 22 * * * 5 *"

My code is:

schedule("0 0 22 * * * 5 *", "sendNotification")

which throws an error:

java.lang.RuntimeException: CronExpression '0 0 22 * * * 5 *' is invalid. on line 69 (method updated)

Any ideas what I'm missing?

P.S. I've also tried wrapping the cron string in '' with no change in behavior:
schedule('"0 0 22 * * * 5 *"', "sendNotification")

You'll want something like this for that cron string instead:

0 0 22 ? * FRI

or

0 0 22 ? * 6

For the general format, see: Cron Trigger Tutorial (docs for the actual scheduler, possibly not the exact version but should be similar enough). For an easy way to make these, there are also resources like: Free Online Cron Expression Generator and Describer - FreeFormatter.com

1 Like

DOPE!
Thank you! I was working off another cron string generator that uses a different format.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.