CiviCRM Cron Job Failing

indieben

Verified User
Joined
Mar 28, 2024
Messages
32
Intention:

To get CiviCRM Scheduled jobs running.

Relevant documentation: https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/

What I have done:
Created an administrative user in WordPress, done nothing with the user in CiviCRM itself taking the view that they are already an administrative user in WordPress anyway. Docs unclear as to what I am supposed to do with the user if anything.

I have tried the wp-cli method and entered:

/usr/local/bin/wp \ --user=redacted \ --url=https://website.uk/members \ --path=/home/userredacted/public_html/members/ \ civicrm api job.execute auth=0

as the cron job. I set it to run at 55 minutes past the hour - and it didn't run.

I've searched high and low and the only documentation is that which is linked above which is as clear as mud to me. I've tried to get to the bottom of it on IRC and people have been as helpful as they can but i'm getting nowhere.

CiviCRM's own chat is dead - there's a chap on there that responds intermittently but seems to have gone quiet and it was dead over the weekend so no support from anywhere to get to the bottom of this.

Thanks.
 
We are not CRM support forums.

Check if cron is running and otherwise create the crontab not via wp-cli but via the Directadmin panel GUI.
 
I have actually created it via the DA panel GUI but I have to call upon one of the methods specified, in this case, wp-cli.

I am struggling with using DA for a specified purpose.

Thanks.
 
You might want to check the crontab log for error notices or check the /var/log/directadmin logfiles to see what is going on.
 
If nothing is changed, according to Google the cron logs are logged into the /var/log/syslog file.
 
Thanks.

Just to say this matter is resolved.

The answer was to put the whole command on one line and remove the several new lines ("\") from the command. The new lines are ignored, this has the effect of other parameters provided being ignored.

So - In this Example (that didn't work):

/usr/local/bin/wp \
--user=redacted \
--url=https://ourwebsite.uk/members \
--path=/home/myukm/public_html/members/ \
civicrm api job.execute auth=0

1. Remove the \ red slashes that I have highlighted above and the command should become:

/usr/local/bin/wp --user=redacted --url=https://ourwebsite.uk/members --path=/home/myukm/public_html/members/ civicrm api job.execute auth=0

(all on one line).

Where - user= I redacted this but this should be your cron user i.e. --user=timsmith
The URL - the URL to your WordPress install index.php file as your visitors would use.

The path - the back end path to the same place - this should be in civicrm.settings.php - as of August 2024 this is located, for WordPress users, at /home/clientusername/public_html/anysubdirectorytowordpressinstallifapplicable/wp-content/uploads/civicrm (don't ask why it's in uploads lol!)

Within this file, see $civicrm_paths['civicrm.private']['path'] = .....

Please note - settings vary (I think) between Drupal, Joomla and WordPress but hopefully this should help someone or a Client running WordPress with CiviCRM installed to get their cron jobs/scheduled tasks running using the WP-CLI method.

Furthermore, you can use the build option in your DA panel admin area to install wp-cli and you will need to for this to work. The resolution detailed in the whole of this post only works for WordPress CiviCRM installs.

If anyone is running cPanel servers as well - it is apparently worth trying adding <path to php-cli> before /usr/local/bin/wp as another member within the CiviCRM community found that the problem for a Client was: "for some odd reason the crontab wasn't immediately invoking php-cli". I didn't need to do this with DA.

As we can see here, Environments like DA and cPanel can and do have their own little quirks. It is most helpful not to immediately dismiss the validity of a post in the DA forums as being related to a third party software provider when there can, and often is, such an obvious cross-over.
 
Last edited:
Back
Top