Cron Schedules not firing

Product: PowerShell Universal
Version: 1.5.16
IIS 10
Server 2016

I tried scheduling jobs daily, weekly, and monthly using cron expressions with no luck. Example “0 0 12 27 1/1 ? *”

Typically, this happens in IIS due to app pool recycling. Can you verify you’ve set these settings: IIS - PowerShell Universal

Yes the suggested settings are set. Scheduled jobs like continuous and one time work. It looks like it’s only happening when I use a cron expression.

When you schedule the jobs, does it show the next run time?

Also, can you check event viewer to see if the app pool is recycling for any reason? You can search for WAS events.

No it doesn’t.

Ah, ok. Then that’s an issue. Can you send a screenshot of the schedules page in your admin console?

I checked for any WAS events. None coming up.

1 Like

When I try to use that CRON expression, I see this error in the logs: Failed to schedule job. CRON expression is invalid. Please see the inner exception for details. (Parameter ‘cronExpression’) Wrong number of parts in the 0 0 12 27 1/1 ? * cron expression, you can only use 5 or 6 (with seconds) part-based expressions.

So is that a bug? I checked the expression on a couple of sites and it said it was valid.

We use hangfire for scheduling and I found a couple of open issues around this. There are some workarounds but it seems like hangfire doesn’t support this format directly. I’ll have to do some research into how to get what you are expecting to work since it doesn’t look like hangfire is going to fix this anytime soon. These issues have been open for some time.

1 Like

Ok. Thanks for the info. Will figure out how to dumb down the expression .

Is this still an issue in regard to the implementation of Hangfire and cron expressions? I’m running latest version and i’ve got one weekly job that is running consistently, but I got another weekly job as well as a daily not executing. I utilized crontab.guru for formatting these out.

0 9 * * Wed - works, every Weds at 9 am
31 5 * * mon - not working, every Monday 5:31am
01 5 * * * - not working, every day 5:01am

I have to chime in here and say that I, too, have experienced the “just one job doesn’t run” issue. I ended up deleting the schedule and re-creating it, and then when I came in the following week PSU thought there were two schedules and tried to run both! Deleted one, and they both disappeared. Re-created it and it has been OK since.

So something weird definitely happens with schedules, but I haven’t been able to narrow down a single cause.

1 Like

I have seen that as well @mabster

1 Like

I actually did delete the schedules and recreate them for the jobs that didn’t run, but I saw zero change in behavior.