CON Job timeout

Hi,
I have a PHP script that takes few minutes to execute everything as it’s fetching data for multiple sources, and I’d like to have this script executed every few minutes.

The problem is that the CRON returns not found.

It’s probably due to timeout issue, as it was happening before when I was loading the page, but now that I increased the PHP max execution time to 5 minutes, it shouldn’t be the case, as I believe that the CRON timeout is also 5 minutes.

How could I resolve this issue?

How exactly do you execute it? If you use /usr/bin/php it should take cgi which itself has an unlimited timeout setting.

I was using only the direct link to the script (e.g.: https://domain.com/script.php)
But I guess I was doing it wrong, and should be doing /usr/bin/php /something/something/public_html/domain.com/script.php

If I use /usr/bin/php do I still need to have the max_execution_time at 300? Or can I set it back to default values?

Thanks :slight_smile:

For CLI default value is 0 / unlimited

Got it! Interestingly, now that I use user/bin/php I get this error:
“PHP Warning: file_put_contents: failed to open stream: Permission denied”

The chmod of the file is read+write, then tried moving it to a folder with the same chmod for the folder, and now can’t access the files in the folder. It says: “Access Denied You do not have permission to view this page. Please check your credentials and try again.”

That’s really interesting that both cases created some sort of errors… I’m confused by this.

Would you happen to know what coul have caused this?

You command that you use is:

/usr/bin/php /home/user/web/domain.com/public_html/file.php?

Yes, that’s correct.

Make sure you add the cronjob under the user and not under root

Also make sure to use the full path include and so on…

That’s correct. I am using the full path in the script. The folder has chmod 775 and the file that is requested to be open with has chmod 766. I’m confused at why the user can’t execute it. Should I change it to sudo?