What should be given as the url to the script while adding it to cron scheduler.
The script is at domain.com/scripts/script.php
PS:I am using cPanel
views:
108answers:
4none of these. but full absolute path from the root of the filesystem. you can see that path with this code
echo __FILE__;
Here's a copy / paste out of one of the cron jobs that I run:
00 7 * * 1,2,3,4,5 /usr/local/bin/php /home/processing/process.php
You must use the absolute path to the PHP binary as well as the absolute path to the script itself.
If you add the line
#!/usr/bin/php
to the beginning of your file (use 'which php' to find out your actual directory) and change the file mod to "executable", you should be able to run it just by calling like your second choice,
/public_html/scripts/script.php
I hope that works for you.
I had the habit of changing directory cd /var/www/vhosts/somesite.com/httdocs
before running script with /usr/bin/php -f ./scriptname.php 2>&1
all in the same line on crontab.
I redirect the error output to get notified by email in case an execution error occured.
From crontab :
[email protected]
* * * * * cd /var/www/vhosts/domain.com/httpdocs/; /usr/bin/php -f testmail.php 2>&1