Using CRON jobs to visit url?
* * * * * wget -O - http://yoursite.com/tasks.php >/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 - http://example.com/backup >/dev/null 2>&1
instead of
wget -q -O /dev/null "http://example.com/backup" > /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 :
chromium-browser http://www.google.com
or
firefox http://www.google.com
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 https://example.com/?pull-feeds=7b2e9c8d534d6c38ca98c726899b6153 -dump
CRON command to run URL address every 5 minutes
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
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
vim cache-clear.sh
#!/bin/bash
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 cache-clear.sh >/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=http://example.com
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 http://example.com/path/to/cron.php &> /dev/null
Related Topics
How to Remove ^[, and All of the Escape Sequences in a File Using Linux Shell Scripting
Bash Script Process Substitution Syntax Error: "(" Unexpected
The Difference Between Fork(), Vfork(), Exec() and Clone()
Redirect Stderr/Stdout of a Process After It's Been Started, Using Command Line
Curl to Access a Page That Requires a Login from a Different Page
How to Programmatically Create a New Cron Job
Register File Extensions/Mime Types in Linux
How to Setup Public-Key Authentication
Setting Environment Variables in Linux Using Bash
How to Set Linux Environment Variables With Ansible
What Is the Maximum Size of a Linux Environment Variable Value
How to Get Cmake to Find My Alternative Boost Installation
Bluetooth Low Energy: Listening For Notifications/Indications in Linux
How to Convert Dos/Windows Newline (Crlf) to Unix Newline (Lf)