I've got a simple script that sends email if you refresh the page. I need it to run every week. I setup a command in CPanel to run that script
php /home/site/public_html/test/sendmail.php
But it does not work. Hosting support says I setup cron in CP correctly.
I wander if I need any intermediate script to run sendmail.php. Thank you for your help in advance.
Most likely you'll need to expand your cron call to /usr/bin/php /home/site/public_html/test/sendmail.php
, because the system can't find the path to the php executable.
You can also add a PHP shebang to the script and run it like a normal shell script without php -f
:
#!/usr/bin/php
<?php
//your code
?>
To get the PHP path, use this code: <?php echo PHP_BINDIR, PHP_EOL; ?>