Cron not working

Search
Other Pre-Sale questions
Forum

Cron not working

Paul's Avatar Paul
Hi,
For now I use Cache Cleaner v8.2.2 in it's free version.
I try to make a CRON job I get in my CRON logs:
500 Internal Server Error
(…)
exitcode: 0

At that moment, in the Error log I get a
aborted: idle timeout (160 sec)


My Cron job is loading every week a php file with that script inside :
$ch1 = curl_init("https://www.my_site.com/index.php?cleancache=ok");
curl_exec($ch1);
curl_close($ch1);
where "ok" is my cleancache secret password

So cache isn't cleaned and weights 2,2Go


I did something wrong?

Thanks for your help.
Paul
Peter van Westen's Avatar Peter van Westen ADMIN
What do you get if you open that url in the browser?

If your homepage is pretty heavy, you could also choose a light simple page for the cronjob instead. For instance:
https://www.my_site.com/my-small-article?tmpl=component&cleancache=ok
The tmpl=component (if your template/site settings allow it) will show the page without the modules. So just the main component part.
Please post a rating at the Joomla! Extensions Directory
Paul's Avatar Paul
Thank you Peter
😉
Paul's Avatar Paul
Well the weekly CRON job has been triggered this night but doesn't work yet…
I got a "301 Moved Permanently"
Could you please help me?


Peter, after your previous post, last week, when I tried to load the url (https://www.my_site.com/index.php?tmpl=component&cleancache=ok) directly from a browser, it was OK. I got no "301 Moved Permanently", and I the site cache had been cleaned as expected.

But this night when the CRON job opened a php file that contains this code:
$ch1 = curl_init("https://www.my_site.com/index.php?tmpl=component&cleancache=ok");
curl_exec($ch1);
curl_close($ch1);
it resulted in a "301 Moved Permanently" in CRON logs and no cache cleaned…



In CRON logs:
[2024-02-19 04:27:02] ## OVH ## START - 2024-02-19 04:27:02.167523 executing: /usr/local/php7.3/bin/php /homez.899/my_site/www/my_cripts/my_cleancache/cleancache.php 
[2024-02-19 04:27:02] <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">[2024-02-19 04:27:02] <html><head>
[2024-02-19 04:27:02] <title>301 Moved Permanently</title>
[2024-02-19 04:27:02] </head><body>
[2024-02-19 04:27:02] <h1>Moved Permanently</h1>
[2024-02-19 04:27:02] <p>The document has moved <a href="https://www.my_site.com/index.php?tmpl=component&amp;cleancache=ok">here</a>.</p>
[2024-02-19 04:27:02] </body></html>
[2024-02-19 04:27:02] 
[2024-02-19 04:27:02] ## OVH ## END - 2024-02-19 04:27:02.397042 exitcode: 0

In Error logs:
I don't get error at [2024-02-19 04:27:02]
Peter van Westen's Avatar Peter van Westen ADMIN
This doesn't have anything to do with Cache Cleaner.
Ask your host why your urls are returning 301 errors via cli and crons.
Maybe a wrong PHP version set for those.
Looking at the output, it is using php 7.3.
Please post a rating at the Joomla! Extensions Directory
Paul's Avatar Paul
Peter, sorry for my newbie naïve answer, but as far as I know, in that case, I am not using CLI.
I just use a CRON task from my hoster to open once a week a PHP file that contains a PHP script.
That script is compatible with 7.3 PHP version otherwise I'd got a CRON error in logs.

It seems that this url "https://www.my_site.com/index.php?tmpl=component&amp;cleancache=ok"
- effectively cleans cache when launched directly from a web browser
- returns a 301 when launched from cURL function in PHP script

Are you sure that it's not Cache Cleaner isn't involved in that?
Peter van Westen's Avatar Peter van Westen ADMIN
- effectively cleans cache when launched directly from a web browser
So Cache Cleaner is working
- returns a 301 when launched from cURL function in PHP script
Ask your host why.
Please post a rating at the Joomla! Extensions Directory
You can only post on this forum if you log in