CLI Job / Cron Runner

CLI Job / Cron Runner 2.1.0

No permission to download

titocento

Member
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

  • cli-runner-verbose.txt
    41.1 KB · Views: 1
Last edited:

Sim

Well-known member
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.
 

titocento

Member
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?
 

titocento

Member
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
 

Sim

Well-known member
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
 

titocento

Member
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.
 

Sim

Well-known member
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.');
        }
 

titocento

Member
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 ;-)
 

Robert9

Well-known member
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.
 

Sim

Well-known member
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.
 

Robert9

Well-known member
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.
 

Sim

Well-known member
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

Well-known member
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...
 
Top