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

2
  • 1
    More information about your setup might help...
    – Eric Booth
    Commented Sep 27, 2017 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
    Commented Apr 19, 2018 at 16:23

1 Answer 1

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.

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.