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