CPanel cron not triggering phpBB system cron

Get help with installation and running phpBB 3.3.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
mikeinthe852
Registered User
Posts: 20
Joined: Sun Aug 09, 2020 11:52 am

CPanel cron not triggering phpBB system cron

Post by mikeinthe852 »

We have a 3.3.0 board with very little traffic.
Outgoing mail sits in queue.php for a long time waiting for board activity.
We wrote a CPanel cron to trigger the board system cron "5 * * * * curl -k -A='Mozilla/5.0' https://theboard/forum/index.php" - does not work!
Use (free) uptimerobot - https://theboard/forum/index.php - does not work!
Use half-hourly website speedtest (14-day trial only) - success, email is sent!

So, what is the difference between the uptime test and speed test? In the past, calling the <img> in overall_footer.html would trigger the board system cron, but it seems in 3.3.0 that has changed? or perhaps the uptime test does not call the <img> but the speed test does? Where is the trigger now? View source on my index page gets no hits for ctrl+f "cron"

What CPanel cron job do I need to write to trigger the board system cron? Different user agent? What am I missing here?

Thanks so much in advance!
mikeinthe852
Registered User
Posts: 20
Joined: Sun Aug 09, 2020 11:52 am

Re: CPanel cron not triggering phpBB system cron

Post by mikeinthe852 »

Support Request Template
What version of phpBB are you using? phpBB 3.3.0 and PHP version: 7.2.32
What is your board's URL? https://forum.nesta.hk/index.php
Who do you host your board with? hub4hosting.uk
How did you install your board? not sure, it was 2008, long before me
What is the most recent action performed on your board? Update from a previous version of phpBB3 - 3.2.2
Is registration required to reproduce this issue? No
Do you have any MODs installed? No
Do you have any extensions installed? Yes
What version of phpBB3 did you update from? phpBB 3.2.2
What extensions do you have installed? Advanced Polls 1.2.3
Digests 3.3.1
Email Login 0.4.0
Google Analytics 1.0.5
phpBB Media Embed PlugIn 1.1.1
[**] User details 3.1.0-RC1
What styles do you currently have installed? prosilver, Absolution, custom
What language(s) is your board currently using? uk engilsh
Which database type/version are you using? MySQL 5
What is your level of experience? New to PHP but not phpBB
What actions did you take (updating your board; installing a MOD, style or extension; etc.) prior to this problem becoming noticeable? Updated from 3.2.2 to 3.3.0
Please describe your problem. cpanel cron is not triggering the board system cron
Generated by SRT Generator
User avatar
P_I
Registered User
Posts: 1499
Joined: Tue Mar 01, 2011 8:35 pm
Location: Staying home - Western Canada
Contact:

Re: CPanel cron not triggering phpBB system cron

Post by P_I »

mikeinthe852 wrote:
Sun Aug 09, 2020 12:20 pm
We have a 3.3.0 board with very little traffic.
Outgoing mail sits in queue.php for a long time waiting for board activity.
There is a setting in ACP->Server settings that you could use.
phpBB - cron settings.JPG
As shown in the image, change Run periodic tasks from system cron: to Yes and then create a cPanel cron job to run

Code: Select all

bin/phpbbcli.php cron:run 
at regular intervals (e.g. every 5 minutes).
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams
mikeinthe852
Registered User
Posts: 20
Joined: Sun Aug 09, 2020 11:52 am

Re: CPanel cron not triggering phpBB system cron

Post by mikeinthe852 »

Thanks P_I great advice, and we may have to go that route eventually. However, triggering the board system cron from the CPanel cron has some advantages, so for now we would like to continue this path. Just need to find the right way to trigger the board system cron.

Any ideas of the mechanism 3.3.0 uses to trigger the cron on board activity?
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 4259
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: CPanel cron not triggering phpBB system cron

Post by thecoalman »

Use the setting P_I pointed out. In Cpanel try this command for cron job.

Code: Select all

/usr/local/bin/php /home/<account>/public_html/phbb_root/bin/phpbbcli.php cron:run
<account> is usually the domain used to create the account and phbb_root is where phpBB is. If the domain were example.com and the forum was accessible from example.com:

Code: Select all

/usr/local/bin/php /home/example/public_html/bin/phpbbcli.php cron:run
If it's accessible from example.com/forum.

Code: Select all

/usr/local/bin/php /home/example/public_html/forum/bin/phpbbcli.php cron:run
Note the .com is not used for directory, just the name. This is typical directory structure for Cpanel but yours may differ.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
mikeinthe852
Registered User
Posts: 20
Joined: Sun Aug 09, 2020 11:52 am

Re: CPanel cron not triggering phpBB system cron

Post by mikeinthe852 »

Thank you thecoalman :) more great advice. But can anyone tell me the actual mechanics of how the cron is triggered from board activity in 3.3.0? Has it changed from 3.2x? Why are the old methods not working any longer?
mikeinthe852
Registered User
Posts: 20
Joined: Sun Aug 09, 2020 11:52 am

Re: CPanel cron not triggering phpBB system cron

Post by mikeinthe852 »

In the past, the board cron was triggered by a user calling an <img> in the overall_footer.html right?
Now in 3.3.x that code in the footer seems to be missing. Thats why "5 * * * * curl -k -A='Mozilla/5.0' https://theboard/forum/index.php" no longer works to trigger the board cron.

I wrote two cron commands and ACP > General > Server configuration > Server settings. Set Run periodic tasks from system cron set to Yes

0 * * * * curl -k -A='Mozilla/5.0' https://board.com/forum/app.php/cron/cron.task.cron_task

1,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/php /home/boarddomain/public_html/forum/bin/phpbbcli.php cron:run


The first command runs the Digest extension, and the second line triggers the mail to go out. Just using the second command did not trigger the Digest, and just using the first command did not trigger the mail. Very odd behavior I think, but the hybrid solution works for my board.
User avatar
MarkDHamill
Registered User
Posts: 4366
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: CPanel cron not triggering phpBB system cron

Post by MarkDHamill »

It sounds to me that a feature has been removed from phpBB, i.e. the whole phpBB cron process which sends out notifications based on board traffic, not on a scheduled interval. It sounds like if you want notifications or any cron process to happen you must use a system cron. On the server settings page for "Run periodic tasks from system cron" in the ACP it says:
When off, phpBB will arrange for periodic tasks to be run automatically.
The question is, is this a bug or a new feature? Either way it needs to be fixed, and if it's a new feature this has to be mentioned as part of the installation process that if you depend on timely notifications you must create a cron process outside of phpBB as another installation step.

I understand in phpBB 4.0 they are planning to roll in an actual cron process somehow. Perhaps this is in preparation for that.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
User avatar
EA117
Registered User
Posts: 2063
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: CPanel cron not triggering phpBB system cron

Post by EA117 »

Back in August, mikeinthe852 had put forth the premise of "Now in 3.3.x that code in the footer seems to be missing." That specific aspect I don't agree with. The cron system runs both as automatically and as conditionally as it always has.

Indeed, no, you do not see a /cron or /cron.php URL in every page, but that has never been the case. RUN_CRON_TASK gets defined if automatic cron processing is enabled & a cron task is actually ready to run, and overall_footer.html includes the link when a task needs to be executed. I used to also think there was a "it won't be invoked more than once every hour for the same session", but I don't actually see the code supporting that recollection.

So to clarify, are you saying "The question is, is this a bug or a new feature?" in reference to the more subtle observation of "when I invoke cron processing by URL, Digest tasks gets executed and email queue processing does not", versus "when I invoke phpbbcli.php cron:run, email queue processing gets executed but Digest tasks do not"?

Or are we still talking about "crons just don't run in phpBB 3.3.x", to which I would say there is ample evidence to the contrary.

On a given board, I could certainly see that maybe the cron task link became deadlocked somehow, or maybe a task is causing a PHP execution error and therefore never completes and is always ready to run again? If I found crons not running on one of my phpBB 3.3.2 boards, that's certainly the direction I would be looking first. Because no, automatic cron processing hasn't "simply been removed."
User avatar
MarkDHamill
Registered User
Posts: 4366
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: CPanel cron not triggering phpBB system cron

Post by MarkDHamill »

Is there a setting which controls if automatic cron processing is enabled? I don't recall every seeing one. If the config value of cron_lock is not 0 it is effectively disabled until the value is 0.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
User avatar
EA117
Registered User
Posts: 2063
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: CPanel cron not triggering phpBB system cron

Post by EA117 »

MarkDHamill wrote:
Thu Dec 24, 2020 2:13 am
Is there a setting which controls if automatic cron processing is enabled? I don't recall every seeing one. If the config value of cron_lock is not 0 it is effectively disabled until the value is 0.
The setting you already mentioned is "the one." "Run periodic tasks from system cron" is "off" by default, which means "crons must be run by phpBB via /cron URLs", and is the state most installations are in. Someone who creates a system cron to invoke phpbbcli.php cron:run will set "Run periodic tasks from system cron" to "on", which means "stop doing the automatic cron processing, because a system cron is going to handle it."

Meaning it's worded as "run from system cron", but could just as accurately be named "disable automatic cron." Since that's what's needed in one case versus the other. You're just toggling "should phpBB handle it" versus "is there a system cron already handling it".

I'm not privy to the history, but the current code is that if cron_lock isn't zero, it's used as a minimum time interval between cron tasks being allowed to run. (set_cron_task() in /phpbb/controller/helper.php) So just based on the code, "cron_lock is non-zero" doesn't mean "disabled", but instead means "won't run tasks any more frequently than cron_lock + 1 hour."

New install schema sets cron_lock to zero. So I don't know what history had this value as non-zero.
User avatar
janus_zonstraal
Registered User
Posts: 5134
Joined: Sat Aug 30, 2014 1:30 pm

Re: CPanel cron not triggering phpBB system cron

Post by janus_zonstraal »

This extension can be helpful.
https://github.com/BoardTools/cronstatus
Sorry! My English is bat ;) !!!
User avatar
MarkDHamill
Registered User
Posts: 4366
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: CPanel cron not triggering phpBB system cron

Post by MarkDHamill »

It appears that crons can't be turned off, just the method of how they are invoked can be changed. Notifications can be disabled but all sorts of things can hook into the cron process. When an asynchronous phpBB cron is invoked, the URL executed is something like:

https://www.mydomain.com/board/app.php/ ... 5418c8b602
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
User avatar
MarkDHamill
Registered User
Posts: 4366
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: CPanel cron not triggering phpBB system cron

Post by MarkDHamill »

I'm also wondering if some sort of security solution is capturing and stopping these requests because they look suspicious. In the past, 1x1 pixel call were considered sneaky. So if some sort of security solution like ModSecurity is enabled, it might be worth seeing if it is blocking these.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
Post Reply

Return to “[3.3.x] Support Forum”