1

Could anyone with more knowledge let me know if I'm doing this setup right. I am on a Dreamhost VPS server.

What I'm trying to do is setup a Cron so the Automatic Schedules/Reminder in our installation of CiviCRM will run..

Cron job via Panel on Dreamhost:

/usr/local/php56/bin/php /home/VPSHOMEDIR/civicrmcron.php

In civicrmcron.php file:

<?php
job.execute;

Do I need to add anything else to the civicrmcron.php file or is this the right way to get cron to run on CiviCRM?

1

See the SysAdmin guide section on scheduled jobs for details of how to set up cron jobs.

For WordPress I use the wp method with a wrapper script:

#!/bin/sh
wp=/path/to/wp       # Path to the wp executable eg /home/X/private/bin/wp
url=https://mysite   # URL of your site eg https://example.org
base=/path/to/wphome # Path to the wordpress installation eg /home/X/www/www

out=`$wp --user=cron --url=$url --path=$base civicrm api job.execute auth=0 2>&1`

if echo $out | grep -qv '\[is_error\] => 0'; then echo $out; fi

Save the wrapper script somewhere, edit the wp, url and base settings, set up a cron user in WP with appropriate permissions, add a cron entry to call this file. Cron suppresses blank output so you only get a mail if something goes wrong.

| improve this answer | |
  • Hi Aidan, thank you for your help. So I placed the above code into my civicrmcron.php file as: <?php #!/bin/sh wp=/usr/local/wp url=http://mywebsite.org base=/home/VPSUSER/mywebsite.org out=$wp --user=kevinv --url=$url --path=$base civicrm api job.execute auth=0 2>&1` if echo $out | grep -qv '[is_error] => 0'; then echo $out; fi;` But the Dreamhost cron email sends me that whole code block back, so its not running. Am I setting up the wrapper script right? – Kevin V Jan 26 '19 at 13:49
  • @KevinV The script I provided is a shell script rather than php. So rename to eg civicrmcron.sh and remove the <?php line so that the file starts with #!/bin/sh – Aidan Jan 28 '19 at 8:02
  • @Aiden I see, sorry for my lack of knowledge these these coding matters. I contacted Dreamhost to see where the path to wp-cli is because I thought it was wp=/usr/local/wp. Their reply was this. The correct path should be, for example: wget -q -O http://yourwebsite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1 Should that go where wp= is? – Kevin V Jan 28 '19 at 23:25
  • There are lots of different ways of running the cron jobs as you can see on the page I linked to. Either can work but this is not the way I was suggesting and you can't mix them. Ask them about 'wp-cli' from wp-cli.org (they should know what it is since they are one of the sponsors!) – Aidan Jan 29 '19 at 0:38
  • @Aiden Can't get this to work. Could I clarify. "user" can be the main Admin WordPress user? Or is this a specific user I need to create in WordPress? set up a cron user in WP with appropriate permissions. – Kevin V Feb 16 '19 at 5:54
1

So after a lot of back and forth with Dreamhost I have gotten Cron to work. Here are the details based of @Aiden answer for anyone else who is on Dreamhost using CiviCRM. Change anything in CAPS below.

CRON JOB ON DREAMHOST'S PANEL

/bin/bash /home/DHUSERNAME/WEBSITEDIRECTORY/civicrmcronjob.sh

SHELL SCRIPT CIVICRMCRON.SH

wp=/usr/bin/wp      
url=https://WEBSITE.COM
base=/home/DHUSERNAME/WEBSITEDIRECTORY

out=`$wp --user=WORDPRESSUSERNAME --url=$url --path=$base civicrm api job.execute auth=0 2>&1`
if echo $out | grep -qv '\[is_error\] => 0'; then echo $out; fi
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.