Centos 7 with selinux set to permissive. Using apache as the user and confirmed apache has execute permissions to the folder and file in plugins/civicrm/civicrm/bin/cli.php

The crontab entry -

1 * * * * apache /etc/php.ini var/www/domainfolder/public_html/wp-content/plugins/civicrm/civicrm/bin/cli.php -s domain.com -u wpuser-cron -p wordpresspasswordhere -e Job -a execute

The error generated is -

X-Cron-Env: <SHELL=/bin/bash>
X-Cron-Env: <PATH=/sbin:/bin:/usr/sbin:/usr/bin>
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <HOME=/usr/share/httpd>
X-Cron-Env: <LOGNAME=apache>
X-Cron-Env: <USER=apache>
Date: Fri, 12 Aug 2016 15:01:01 -0400 (EDT)
Status: RO

/bin/bash: /etc/php.ini: Permission denied

Running it as the user apache definitely seems wrong. I did so just to see that I could get the cron job running properly; then revisit selinux settings to deal with creating a group with the correct permissions and a cron user for this job.

1 Answer 1


This cron job calls /etc/php.ini as the command, but that file is not an executable (it's the default configuration file for PHP).

(The "Permission denied" error is the same as if you asked "run the script README.TXT" - the file doesn't have exec bit set because it's not a program at all.)

Try this -

1 * * * * apache /usr/bin/php /var/www/example.org/public_html/wp-content/plugins/civicrm/civicrm/bin/cli.php -s domain.com -u wpuser-cron -p wordpresspasswordhere -e Job -a execute

Your PHP path may not actually be /usr/bin/php, so check the correct path by typing which php at a commandline and use that.

Running it as the user apache definitely seems wrong.

This is OK. It means that CiviCRM when executed from cron and from the web will generate files using the same user - CiviCRM can have issues when it hits file access issues between multiple users, so using a single user for both www and cron is the simplest solution.

  • I'm not sure how I had the ini file in the command. I corrected it with php, added a user to apache group and the command ran fine. Adding the final crontab for reference - 15 * * * * <systemuser> php /var/www/domainfolder/public_html/wp-content/plugins/civicrm/civicrm/bin/cli.php -s domain.com -u wpuser -p wppasswordhere -e Job -a execute
    – eauxnguyen
    Commented Aug 13, 2016 at 20:01
  • I can't see the rest of your comment, but: running both cron and www as apache is the simplest configuration. It has issues (eg if there are other sites on the same host), but doing anything more advanced will require a deeper understanding of UNIX permissions. Your new user AND the apache user will both need to have default ownership and permissions which share nicely between the two accounts. Commented Aug 13, 2016 at 20:03
  • Sorry I was mid edit and surprised at the lack of line breaks in comments. It's not on a shared host server. By adding the user to the same group as the apache user I was able to get this working. Thanks for your attention to this question. I appreciate it.
    – eauxnguyen
    Commented Aug 13, 2016 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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