# What is the best way to add a cron job with URL?

**URL:** <https://forum.hestiacp.com/t/what-is-the-best-way-to-add-a-cron-job-with-url/2112>\
**Category:** Cron Jobs\
**Created:** [November 17, 2020, 4:01am UTC](https://forum.hestiacp.com/t/what-is-the-best-way-to-add-a-cron-job-with-url/2112 "2020-11-17T04:01:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnzapf](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/johnzapf/32/983_2.png) [@johnzapf](https://forum.hestiacp.com/u/johnzapf)\
**Post date:** [November 17, 2020, 4:01am UTC](https://forum.hestiacp.com/t/what-is-the-best-way-to-add-a-cron-job-with-url/2112/1 "2020-11-17T04:01:37Z")

</div>

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](http://website.com/folder/file.php)

And this is what I get back:  
/bin/sh: 1: [http://website.com/folder/file.php:](http://website.com/folder/file.php:) not found

---

<div class="post-metadata">

**Author:** ![pluto](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/p/f08c70/32.png) [@pluto](https://forum.hestiacp.com/u/pluto)\
**Post date:** [November 17, 2020, 4:26am UTC](https://forum.hestiacp.com/t/what-is-the-best-way-to-add-a-cron-job-with-url/2112/2 "2020-11-17T04:26:20Z")

</div>

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](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](http://website.com/folder/file.php)”

---

<div class="post-metadata">

**Author:** ![johnzapf](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/johnzapf/32/983_2.png) [@johnzapf](https://forum.hestiacp.com/u/johnzapf)\
**Post date:** [November 17, 2020, 2:56pm UTC](https://forum.hestiacp.com/t/what-is-the-best-way-to-add-a-cron-job-with-url/2112/4 "2020-11-17T14:56:39Z")

</div>

Thanks.

---

<div class="post-metadata">

**Author:** ![johnzapf](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/johnzapf/32/983_2.png) [@johnzapf](https://forum.hestiacp.com/u/johnzapf)\
**Post date:** [November 17, 2020, 3:00pm UTC](https://forum.hestiacp.com/t/what-is-the-best-way-to-add-a-cron-job-with-url/2112/5 "2020-11-17T15:00:12Z")

</div>

Thank you, curl “[http://website.com/folder/file.php](http://website.com/folder/file.php)” is working great

---

<div class="post-metadata">

**Author:** ![falzo](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/falzo/32/10_2.png) [@falzo](https://forum.hestiacp.com/u/falzo)\
**Post date:** [November 17, 2020, 3:18pm UTC](https://forum.hestiacp.com/t/what-is-the-best-way-to-add-a-cron-job-with-url/2112/6 "2020-11-17T15:18:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bnev](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/bnev/32/580_2.png) [@bnev](https://forum.hestiacp.com/u/bnev)\
**Post date:** [December 6, 2020, 12:28pm UTC](https://forum.hestiacp.com/t/what-is-the-best-way-to-add-a-cron-job-with-url/2112/8 "2020-12-06T12:28:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![eris](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/eris/32/1241_2.png) [@eris](https://forum.hestiacp.com/u/eris)\
**Post date:** [December 6, 2020, 1:24pm UTC](https://forum.hestiacp.com/t/what-is-the-best-way-to-add-a-cron-job-with-url/2112/9 "2020-12-06T13:24:09Z")

</div>

use /usr/bin/php or /usr/bin/php7.4
