2

I'll try to be as thorough as I can while getting straight to the point. I am brand new to the idea of using WP-CLI, SSH, and Scheduled Cron jobs. Everything is Greek to me, so I am in desperate need of help.

I'm trying to remove the System Network Error that's triggered because scheduled cron jobs aren't set up on CiviCRM (v5.17.2).

The site is hosted on Dreamhost (shared server). I tried following the help documentation on CiviCRM's website (https://docs.civicrm.org/sysadmin/en/stable/setup/jobs/). I've completed steps one and two. The only scheduled job api that's active is the default version check job. The log came back with a "success" message when I executed it manually.

With step 3, I tried the WP-CLI method since it's a WordPress site. I tried multiple combinations. I wasn't sure exactly how to call the job.version_check api. The instructions said to have a path to wp-cli, so I assumed that it would be to the folder in the plugin. When I did, I got back a message saying "this is a directory", which I assume was good and it would work (although, I wasn't sure what I was calling since there's just the "civicrm.php" file in the folder). Reading further in the article, I though I was to have it point to the "cli.php" or the "cron.php" files in the bin directory of the plugin. Each time, I would get a "permissions denied" message. I would change the permissions of the files and I would get "no such file or directory" and "command not found" messages, along with the "permissions denied" message.

When I got the "this is a directory" message, I moved on to step 4 and created a scheduled cron job using Dreamhosts' cron scheduler. I would still get back "permissions denied" messages. So, I read this article (https://civihosting.com/blog/how-to-make-a-cron-job-for-civicrm/) and created a .sh file. After it was all said and done, this was the last message I got:

sh: /home/dh_6x6vh8/civicron.sh: /bin/sh^M: bad interpreter: No such file or directory

Now, I'm stuck and I have no idea what to do or what I'm doing. I'm sorry for such a long explanation, but I wanted to make sure I was thorough without being too lengthy (which I did more, but it's a long story... if your interested in full details, please reach out). If there's a wonderful person in this system who can help me, please understand that I'm very new with cron jobs/SSH/CLI/etc, so whatever instructions you give, you'll have to talk to me like a little kid. Thank you so much for your help!

2

I just set it up with dreamhost shared hosting. I went into cron jobs in my dreamhost control panel and added a new job. under command to run I put "/usr/bin/php /home/DREAMHOST-USER/EXAMPLE.COM/wp-content/plugins/civicrm/civicrm/bin/cli.php -u WP-USER -p WP-USER-PASS -e Job -a execute" Obviously leave out the quotation marks and change all the sections in CAPITAL letters

  • Hi @netzih ! Thank you for your comment. I tried that and unfortunately I got back the following error: sh: /usr/bin/php/home/DREAMHOST-USER/WEBSITE.COM/wp-content/plugins/civicrm/civicrm/bin/cli.php: Not a directory – Brandon Oct 19 at 21:12
  • I made a change to the directory by taking off the /usr/bin/php part and now it's working. Thank you!! – Brandon Oct 19 at 21:44
  • Interesting, it seems you did not put a space after /usr/bin/php. That part is just telling the cron where php is located. Than after that space you put the directory which is /home/..... – netzih Oct 20 at 3:19
  • Funny you said that, @netzih. I recently updated CiviCRM which led to a "Permissions Denied" cron error. I came back to the article and added the /usr/bin/php (note the space) at the beginning. Now, it's working perfectly again. So, your fix still works. :) Thank you! – Brandon Nov 4 at 20:43
0

Welcome to SE! The error includes /bin/sh^M: bad interpreter. The ^M part suggests you created the file on a Windows machine and copied it to your Linux server. Linux and Windows have different conventions for marking the end of a line. See this for more explanation.

For are many ways to fix that. If you have ssh to the Linux box try running this to convert the line endings:

dos2unix /home/dh_6x6vh8/civicron.sh

There are many other reasons why your cron job might not be working but this should get you past the 'bad interpreter' problem.

  • Hi, @Aidan ! Thank you for your reply, your insight, and welcome! – Brandon Oct 19 at 21:45

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.