Using Cron Jobs to Visit Url

Using CRON jobs to visit url?

* * * * * wget -O - >/dev/null 2>&1

That should work for you. Just have a wget script that loads the page.

Using -O - means that the output of the web request will be sent to STDOUT (standard output)

by adding >/dev/null we instruct standard output to be redirect to a black hole.
by adding 2>&1 we instruct STDERR (errors) to also be sent to STDOUT, and thus all output will be sent to a blackhole. (so it will load the website, but never write a file anywhere)

cron job to run url cpanel

use this

wget -q -O - >/dev/null 2>&1

instead of

wget -q -O /dev/null "" > /dev/null 2>&1

Using Cron to open and visit URL's

For some reason xdg-open doesn't work correctly when used in association with crontab.

You can tweak your way around to get the job done by using any of the following commands :
based on your browser.

Creating a Cron job for URL

Please use lynx text browser (if your server does not have lynx, install it).

then use

 */5 * * * * /usr/bin/lynx -dump

CRON command to run URL address every 5 minutes

Based on the comments try

*/5 * * * * wget

[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:

Using Crontab to Visit Multiple URLs with Wget

You can write a bash script to clear cache for all this sites from a single file


wget -O - "https://domain1/?action=wpfastestcache&type=clearcache&token=ABCD" >/dev/null 2>&1
wget -O - "https://domain2/?action=wpfastestcache&type=clearcache&token=ABCD" >/dev/null 2>&1
wget -O - "https://domain3?action=wpfastestcache&type=clearcache&token=ABCD" >/dev/null 2>&1

Then run this bash script from crontab , suppose you want to clear cache every 10 minutes

crontab -e ---> to edit crontab

*/10 * * * *  bash >/dev/null 2>&1

Run this script from crontab every 10th minute by adding above command in crontab

Get the url of cron job

The <?=$_SERVER['HTTP_HOST'];?> will will not be populated when running it from a cronjob like php -q /home/karenib/public_html/scr/cron.php, since the file is not accessed via HTTP.

You can pass the host through params like

php -q /home/karenib/public_html/scr/cron.php -h=

And access it like

$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : getopt('h:');

However, if you still need the HTTP_HOST populated, you can use curl like

curl &> /dev/null

Related Topics

Leave a reply