Chron Job Not Running

I see some older posts about chron jobs not running but they don’t seem to apply to what I’m seeing.

Basically I was able to create a chron job that would run once a day. However I needed to modify the frequency to at least twice a day and the only way I found to do that was to delete the old chron job and set up a new one.

So I deleted the old job and created a new chron job…And now it never runs. I’ve tried recreating it with different run frequencies and it never runs automatically.

Any help?

In the meantime, I’m using a workaround where I can trigger it manually from my webpage. It runs perfectly fine in that situation but it totally defeats the point of a chron job.

Hi @jdischler!

What is your website address?

The site is at: http://clash-wisconsin.online

Is that what you are asking?

Yes.

I have checked it. The cron job schedules a PHP script. ‘up’ script does not exist.

1 Like

Ok, the script name appears to auto-complete once I type ‘up’ (the full script name is ‘update-stuffs.php’)… and since it appears to have filled in the script name for me, I stop typing and say ‘OK’.

I’ll try typing the entire script name just to be safe.

Thanks for the details.

You’re welcome. Please reply whether the issue is solved or not :slight_smile:

Yes, it is now starting up at the scheduled frequency, thanks for the help!

Related to this script though, I’m still having a chron job problem. Is there a limit to how long a chron job can run?

Here’s the background on this script:

I can trigger this script from my browser URL as a test. It needs about 30 sec to 1 min to complete but it works perfectly fine.

But as a chron job, something seems to terminate it after a few seconds. I don’t see any obvious errors but it’s easy to see that the process only gets part way through because only a few records got updated.

The script might be unusual in that it requests data from a provider and there are limits. I can request 1 data update at a time and I can’t make more than about 3 requests per second.

Since this script is trying to update/synchronize dozens of records, the script is always going to take a minimum of 30 seconds to complete.

I put a usleep(300000); between the requests thinking it should let the process wait in a cpu friendly way before trying to make the next request. But maybe something watching the chron job is forcing my script to stop before it’s actually done?

Ideas?
-Jeff

Is there a limit to how long a chron job can run?

As far as I can tell, a PHP script can run max 30 seconds per session (http://phplatestinfo.000webhostapp.com/ > max_execution_time). I don’t know about cronJobs though, because they run on separate servers.

I’ll ask a developer about it and get back to you as soon as I get an answer.

Interesting. 30 seconds sounds about right. I update a timestamp when the records are updated and the time range of updated records covers about that time.

For whatever reason, though, the script is usually able to complete within that timeframe when I run it via the URL. Perhaps cron jobs run lower priority (slower)?

Most likely CronJobs have a maximum execution time lower than 30 seconds, but I’ll wait for developers to give the verdict :slight_smile: