I'm newbie in cron commands and I need help.
I have a script on http://example.com/check/
.
Whats is command for cron to run this URL every 5 minutes?
I tried
*/5 * * * * /home/test/check.php
But I want to run URL not relative script address. How to do it?
Based on the comments try
*/5 * * * * wget http://example.com/check
[Edit: 10 Apr 2017]
This answer still seems to be getting a few hits so I thought I'd add a link to a new page I stumbled across which may help create cron commands: https://crontab.guru
使用卷曲:
*/5 * * * * curl http://example.com/check/
使用 curl 的另一个优点是,如果需要,您还可以通过使用$_GET
、 $_POST
等来保留将参数发送到脚本的 HTTP 方式,如下所示:
*/5 * * * * curl --request GET 'http://exemple.com/path/check.php?param1=1¶m2=2'
Here is an example of the wget script in action:
wget -q -O /dev/null "http://example.com/cronjob.php" > /dev/null 2>&1
Using -O
parameter like the above means that the output of the web request will be sent to STDOUT
(standard output).
And the >/dev/null 2>&1
will instruct standard output to be redirected to a black hole. So no message from the executing program is returned to the screen.
Nothing worked for me on my linux hosting. The only possible commands they provide are:
/usr/local/bin/php absolute/path/to/cron/script
and
/usr/local/bin/ea-php56 absolute/domain_path/path/to/cron/script
This is how I made it to work: 1. I created simple test.php file with the following content:
echo file_get_contents('http://example.com/check/');
2. I set the cronjob with the option server gived me using absolute inner path :)
/usr/local/bin/php absolute/path/to/public_html/test.php
To run a URL simply use command below easy yess CPanel 100%
/usr/bin/php -q /home/CpanelUsername/public_html/RootFolder/cronjob/fetch.php
I hope this help.
我尝试GET 'http://example.com/?var=value'
重要使用'
add >/dev/null 2>&1
以便在激活时不发送电子邮件对不起我的英语
I find this solution to run a URL every 5 minutes from cPanel you can execute any task by this command.
*/5 * * * *
This on run At every 5th minute. so it only runs once in one hour
Here is an example that i use to run my URL every second
*/5 * * * * curl http://www.example.com/;
sleep 5m; curl http://www.example.com/;
sleep 5m; curl http://www.example.com/;
sleep 5m; curl http://www.example.com/;
sleep 5m; curl http://www.example.com/;
sleep 5m; curl http://www.example.com/;
sleep 5m; curl http://www.example.com/;
sleep 5m; curl http://www.example.com/;
sleep 5m; curl http://www.example.com/;
sleep 5m; curl http://www.example.com/;
sleep 5m; curl http://www.example.com/;
sleep 5m; curl http://www.example.com/;
To sleep for 5 seconds, use:
sleep 5
Want to sleep for 5 minutes, use:
sleep 5m
Halt or sleep for 5 hours, use:
sleep 5h
If you do not want any email of cron job just add this to end of the command
>/dev/null 2>&1
Use perfect url
*/5 * * * * wget -q -O /dev/null "https://www.example.com/payment/WebhookOrderCron" > /dev/null 2>&1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.