I am trying to add a cron job and I usually just add the URL to the file but when I do that I get an email back saying its not found. What am I doing wrong?
This is what I add and I know it works (example): http://website.com/folder/file.php
And this is what I get back:
/bin/sh: 1: http://website.com/folder/file.php: not found
For a start, you definitely need to add the cron job for a user through the web interface or command line v-add-cron-job
Secondly you need to add a program which will access the url, such as curl or wget, so the command would be
You might also want to add options to curl. See the man page.
Finally to make it bulletproof, you’d probably want to surround the URL with quotes, and use the full path to curl, so
/usr/bin/curl [options] “http://website.com/folder/file.php”
Thank you, curl “http://website.com/folder/file.php” is working great
it shouldn’t be neccessary to run that through the webserver itself each time.
rather use the cli command for your php version with the correct local path to that file and run it directly. add -q to surpress output and unneccassary mail notifications, e.g.
php7.3 -q /home/user/web/domain.tld/public_html/folder/my.php
be aware that the settings for php-cli might differ from those for php-fpm.
I’m having some difficulty with with getting a cron to run a php file as well. Previously coming from VestaCP, I was able to add a cron via the admin panel, such as:
php /home/user/web/domain.tld/public_html/folder/file.php > /dev/null 2>&1
I’ve tried this in HestiaCP, but it doesn’t appear to run. I’ve also tried to specify the php version at the start of the cron command and use “-q” rather than “> /dev/null 2>1”, as follows:
php7.4 -q /home/user/web/domain.tld/public_html/folder/file.php
When this ran on my previous server using VestaCP, it would generate a new file, based on the file being ran in the cron script in a specific folder every 15 minutes (per the cron).
I can not seem to get this to work on my HestiaCP install and wondered if anyone had any suggestions or things I could look for that are going wrong, or that I have missed.
use /usr/bin/php or /usr/bin/php7.4