CRON command to run URL address every 5 minutes
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
Use cURL:
*/5 * * * * curl http://example.com/check/
The other advantage of using curl is that you also can keep the HTTP way of sending parameters to your script if you need to, by using $_GET
, $_POST
etc like this:
*/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.