0

Need your help....I'm trying to setup cron jobs using the cli.php command given in the documentation....I'm able to run it directly through the terminal...but when I schedule it via cPanel its gives me an error 'cli.php can only be run from command line.'

  • 1
    More information about your setup might help... – Eric Booth Sep 27 '17 at 15:28
  • @guru316 if you provide more info on your setup - I can provide CPanel instructions. I would need to know what version of Civi and what CMS. – themak Apr 19 '18 at 16:23
1

if your user has cron access, you can always create a file, call it cron for simplicity sake, in the file add the command you wish to run, for example mine is a bit interesting cause I have to export my civicrm settings at the same time:

export CIVICRM_SETTINGS="/home/domain/public_html/administrator/components/com_civicrm/civicrm.settings.php"    
cv api --user=cron job.execute

mind you, thats using the CV command, however, this can still be implemented via the cli.php. Example:

 /path/to/php /path/to/civcrm/bin/cli.php \
  -s example.org \
  -u myusername \
  -p mypassword \
  -e Job \
  -a execute

save that in the file you created earlier (with your changes of course), then with cpanels cron, just set the command/job to execute:

sh cron > /dev/null

or

sh cron > /home/domain/logs/cron.log

just make sure the file is outside of the web folder and is executable.

| 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.