CLI Job / Cron Runner

CLI Job / Cron Runner 2.1.0

No permission to download
That's strange - it is indicating that the Cron task has never been run.

Look in your xf_job table - there should be an entry for "cron" with the last_run_date column set - if it is blank, then your XF crons aren't running.

Temporarily turn off your unix cron task and then run hg:run-jobs -vvv to show full debug output and either post here or message me with the log output.

What version of XF are you running? Which version of the addon?

I'm running XF 2.2.1 and CLI Runner 2.0.0

Here we go, i set cron to daily, and ran the command verbose output, attached as forum doesn't allow me to post that much characters.

Funny thing is now if i do show:jobs command it has set the date

1605549155960.png

Should i reenable the cron every minute or there is something to fix?

Regards,
 

Attachments

Last edited:
I'm running XF 2.2.1 and CLI Runner 2.0.0

Here we go, i set cron to daily, and ran the command verbose output, attached as forum doesn't allow me to post that much characters.

Funny thing is now if i do show:jobs command it has set the date

View attachment 239797

Should i reenable the cron every minute or there is something to fix?

Regards,

Okay, there's a couple of things happening here.

First up, it does seem like your OS cron task is not running - how do you have it set up? Is this on Linux? Can you share your crontab where you execute hg:run-jobs ?

Secondly, the reason the times are a bit off for the XF cron job is that you have an XF cron task samDisableExpiredAds from Siropu\AdsManagerLite which is running every minute.

That means that there will always be more tasks for the cron system to execute, and so it will never look like it's ever finished - the Next Run time is never going to be more than 1 minute away from the last run.

While it might be justified having an addon run an XF cron task every minute - personally I think in the majority of cases it will add unnecessary load to the server and is poor form. I'd be asking the developer of AdsManagerLite about whether it is really necessary or a good idea to be running that Disable Expired Ads cron task so frequently.
 
Hi, it's cpanel, at the moment i sent you that i set crontab to daily as you told me to disable it. Previously it was set to every minute.

I set it back to every minute now, via cpanel interface, and i checked after doing a crontab -e, which shows this:

* * * * * php /home/whatever/public_html/xenforo/cmd.php hg:run-jobs (i edited the paths but you get it).

Command is fine as i tried it from terminal and it executes correctly.

About siropu ads executing xf cron task every minute, i understand this is why it tells some tasks are pending?
 
Apparently it isn't running for Xenforo according to the show-jobs output, but i have other php scripts that execute cron and work on the same server. Very strange.

1605660786016.png
 
Which user does the unix cron task run as?

If it's not the web server user, that may be a source of issues.

Are there any cron related errors in syslog?

Can you set up cron email to receive emails containing the output from your cron tasks - that would help with debugging.

Alternatively, redirect output to a temporary file and turn on full debug output:

* * * * * php /home/whatever/public_html/xenforo/cmd.php hg:run-jobs -vvv > /tmp/xenforo-`date +\%Y\%m\%d\%H\%M\%S`-cron.log 2>&1
 
hi, it seems the unix cron task runs as the same user than our website (specific user, not root, not nobody).

There is no cron errors in syslog, but the log shows that error:

tail -f cron.log This script can only be run via the command line interface. Content-type: text/html; charset=UTF-8 This script can only be run via the command line interface.
 
hi, it seems the unix cron task runs as the same user than our website (specific user, not root, not nobody).

There is no cron errors in syslog, but the log shows that error:

tail -f cron.log This script can only be run via the command line interface. Content-type: text/html; charset=UTF-8 This script can only be run via the command line interface.

what happens when you execute as the web server user? Something like: sudo -u <web server username> php cmd.php hg:run-jobs

The very first thing the XF CLI runner does is check we're running in CLI mode:

PHP:
        if (PHP_SAPI != 'cli')
        {
            die('This script can only be run via the command line interface.');
        }
 
fixed, i don't know if it's related to cpanel multiphp, Litespeed web server own LSAPI or Cloudlinux alt-php but specifying which PHP path we want to execute it works, cron line is like this now:

* * * * * /usr/local/cpanel/3rdparty/php/73/bin/php /home/whatever/public_html/xenforo/cmd.php hg:run-jobs

thanks for all your help ;-)
 
Is it possible that this addon manipulates my cron-jobs somehow?
After upgrading to 2.2.something deactivated cron-jobs are still runing in my test-forum.
 
Is it possible that this addon manipulates my cron-jobs somehow?
After upgrading to 2.2.something deactivated cron-jobs are still runing in my test-forum.

No, this addon does not change the activation status of cron jobs.

Is it possible that you had a heap of queued jobs that hadn't been run because there was no traffic on your test forum which then got executed when you switched to the CLI job runner?

FYI the hg:run-cron command using the -f or --force option will execute disabled cron tasks.
 
All i can say is, that i have a forum on a small NUC that is used to fetched data from some pages in the web.
This machine runs since month, doing nothing else. Sometimes i activate a second cron for some days, then i deactivate it again.
After upgrading xf to the last version the deactivation of this cron job doesnt stop him from running like before.
 
All i can say is, that i have a forum on a small NUC that is used to fetched data from some pages in the web.
This machine runs since month, doing nothing else. Sometimes i activate a second cron for some days, then i deactivate it again.
After upgrading xf to the last version the deactivation of this cron job doesnt stop him from running like before.

Could be a bug in the cron job? Is it custom built or from an addon?

I would need more data to help problem solve.

Perhaps turn on debugging and save the output from the cron runner to give you more of an idea about what is happening?
 
Sim updated CLI Job / Cron Runner with a new update entry:

v2.1.0 update and bugfixes

Update
  • had required parameters after optional parameters - re-arranging logJobProgress function signature to make it more usable
  • added new option --reset to delete any existing lockfile - useful in situations where a job has crashed without removing the lock and you don't want to wait 10 minutes for the lock to expire
Important: if you also run my SparkPost...

Read the rest of this update entry...
 
Thanks for this add-on, using it on my staging server.

Question though, is it possible to run batch update threads jobs? I can see them with the show-jobs command:
Code:
+----------------+-----------------+----------------------+----------------------+
| Key            | Class           | Next Run             | Last Run             |
+----------------+-----------------+----------------------+----------------------+
| forumDelete28  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete33  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete34  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete38  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete40  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete41  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete50  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete51  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete55  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete57  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete58  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete64  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete67  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete69  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete43  | XF:ForumDelete  | 26-Nov-2021 09:36:28 |                      |
| forumDelete44  | XF:ForumDelete  | 26-Nov-2021 09:36:28 |                      |

But they don't process when I run a run-jobs command.

(It's a very large job and would be cool if I can run it on the CLI instead of in the GUI backend)
 
Thanks for this add-on, using it on my staging server.

Question though, is it possible to run batch update threads jobs? I can see them with the show-jobs command:
Code:
+----------------+-----------------+----------------------+----------------------+
| Key            | Class           | Next Run             | Last Run             |
+----------------+-----------------+----------------------+----------------------+
| forumDelete28  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete33  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete34  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete38  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete40  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete41  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete50  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete51  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete55  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete57  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete58  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete64  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete67  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete69  | XF:ForumDelete  | 26-Nov-2021 09:35:16 |                      |
| forumDelete43  | XF:ForumDelete  | 26-Nov-2021 09:36:28 |                      |
| forumDelete44  | XF:ForumDelete  | 26-Nov-2021 09:36:28 |                      |

But they don't process when I run a run-jobs command.

(It's a very large job and would be cool if I can run it on the CLI instead of in the GUI backend)

They should be processed by run-jobs ... do the forums you are deleting have a large number of threads in them?

Is your staging server underpowered so the database updates are actually happening slowly giving the impression that they aren't being processed?

Perhaps try running from the CLI with the debug verbosity level: hg:run-jobs -vvv ... that should show you more about what's happening.
 
Yes, a lot of threads/replies (about 2.5k/35k).

And the staging server is extremely underpowered. A NAS with a Celeron processor...

Will try the debug variant because deleting with the gui takes hours and hours...
 
  • Like
Reactions: Sim
Top Bottom