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?
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
curl http://website.com/folder/file.php
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”
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.
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.