Answers.Body: <p>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.</p>
  
  <p>CRON JOB ON DREAMHOST'S PANEL</p>
  
  <pre>/bin/bash /home/DHUSERNAME/WEBSITEDIRECTORY/civicrmcronjob.sh</pre>
  
  <p>SHELL SCRIPT CIVICRMCRON.SH</p>
  
  <pre>
  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
  </pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-20T10:26:21.453Z
Answers.LastActivityDate: 2019-02-20T10:26:21.453Z
Answers.UserDisplayName: Kevin V
Answers.Body: <p>See the <a href="https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/" rel="nofollow noreferrer">SysAdmin guide section on scheduled jobs</a> for details of how to set up cron jobs.</p>
  
  <p>For WordPress I use <a href="https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/#wp-cli" rel="nofollow noreferrer">the <code>wp</code> method</a> with a wrapper script:</p>
  
  <pre><code>#!/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&gt;&amp;1`
  
  if echo $out | grep -qv '\[is_error\] =&gt; 0'; then echo $out; fi
  </code></pre>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-26T13:49:49.087Z
Answers.Text: 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?
Answers.UserDisplayName: Kevin V
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-28T08:02:25.950Z
Answers.Text: @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`
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-28T23:25:51.810Z
Answers.Text: @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?
Answers.UserDisplayName: Kevin V
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-29T00:38:56.630Z
Answers.Text: 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!)
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-16T05:54:55.717Z
Answers.Text: @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`.
Answers.UserDisplayName: Kevin V
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-18T10:18:35.280Z
Answers.Text: It's common to create a user specifically for use with cron, but to get things started you can use the main admin user so that you don't have any permissions issues.  Once that is working you could switch to a different user with more limited permissions.
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T09:08:24.503Z
Answers.LastActivityDate: 2019-01-25T09:08:24.503Z
Answers.UserDisplayName: Aidan
Answers.Body: <p>Based on Kevin V's answer - a variation that worked for me was the following:</p>
  <p>Change anything in CAPS below.</p>
  <p>CRON JOB ON DREAMHOST'S PANEL</p>
  <pre>/bin/bash /home/DHUSERNAME/WEBSITEDIRECTORY/civicrmcronjob.sh</pre>
  <p>SHELL SCRIPT CIVICRMCRON.SH</p>
  <pre>
  /usr/bin/php /home/DHUSERNAME/WEBSITEDIRECTORY/wp-content/plugins/civicrm/civicrm/bin/cli.php -u WPUSER -p WPUSERPASSWORD -e Job -a execute
  </pre>
  <p>The bit I got stuck with was the user/password situation. In WordPress, create an admin user called CRON, who's only job is to be the user referred to above.</p>
  <p>Also calling the script correctly, as it changes over time as new php versions come along. ref: <a href="https://help.dreamhost.com/hc/en-us/articles/215088668" rel="nofollow noreferrer">https://help.dreamhost.com/hc/en-us/articles/215088668</a>
  Search Dreamhost's knowledge base for &quot;path's to common programs&quot;.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-23T13:18:57.580Z
Answers.LastActivityDate: 2021-09-23T13:18:57.580Z
Answers.UserDisplayName: Ugh_tC
Body: <p>Could anyone with more knowledge let me know if I'm doing this setup right.
  I am on a Dreamhost VPS server.</p>
  
  <p>What I'm trying to do is setup a Cron so the Automatic Schedules/Reminder in our installation of CiviCRM will run..</p>
  
  <p>Cron job via Panel on Dreamhost:</p>
  
  <pre><code>/usr/local/php56/bin/php /home/VPSHOMEDIR/civicrmcron.php
  </code></pre>
  
  <p>In civicrmcron.php file:</p>
  
  <pre><code>&lt;?php
  job.execute;
  </code></pre>
  
  <p>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?</p>
  
Tags: <cron><cron-job>
Title: Can't get Cron to run on WordPress CiviCRM via Dreamhost - am I doing it right?
ThreadText: # Can't get Cron to run on WordPress CiviCRM via Dreamhost - am I doing it right?
  
  (Asked by: username_0 on 2019-01-25)
  
  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?
  
  **Tags:** cron, cron-job
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2019-02-20. Score: 2 | Accepted answer
  
  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
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2019-01-25. Score: 2
  
  See the [SysAdmin guide section on scheduled jobs](https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/) for details of how to set up cron jobs.
  
  For WordPress I use [the `wp` method](https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/#wp-cli) 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.
  
  > **Comments:**
  > **username_0**: Hi username_1, 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=username_0 --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?  
  > **username_1**: @username_0 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`  
  > **username_0**: @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?  
  > **username_1**: 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!)  
  > **username_0**: @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`.  
  > **username_1**: It's common to create a user specifically for use with cron, but to get things started you can use the main admin user so that you don't have any permissions issues.  Once that is working you could switch to a different user with more limited permissions.  
  
  ---
  
  ### Answer by username_2 on 2021-09-23. Score: 1
  
  Based on username_0's answer - a variation that worked for me was the following:
  
  Change anything in CAPS below.
  
  CRON JOB ON DREAMHOST'S PANEL
  
  ```
  /bin/bash /home/DHUSERNAME/WEBSITEDIRECTORY/civicrmcronjob.sh
  ```
  
  SHELL SCRIPT CIVICRMCRON.SH
  
  ```
  
  /usr/bin/php /home/DHUSERNAME/WEBSITEDIRECTORY/wp-content/plugins/civicrm/civicrm/bin/cli.php -u WPUSER -p WPUSERPASSWORD -e Job -a execute
  
  ```
  
  The bit I got stuck with was the user/password situation. In WordPress, create an admin user called CRON, who's only job is to be the user referred to above.
  
  Also calling the script correctly, as it changes over time as new php versions come along. ref: <https://help.dreamhost.com/hc/en-us/articles/215088668>
  Search Dreamhost's knowledge base for "path's to common programs".
  
  
  ---
  
  