How do I call a web page in the Unix cron?

Posted on 2007-11-21
Last Modified: 2013-12-26
I have a web page that performs some sql statements against a database. All I have to do to perform the operations is go to¶m2=xyz. There's no user intervention needed, the page just does it. How do I call this web page from the cron so it calls it on a scheduled basis?
Question by:bemara57

Assisted Solution

overflow34 earned 50 total points
ID: 20329777

Try this link.  I think this is what you are looking for.
LVL 21

Accepted Solution

robocat earned 200 total points
ID: 20329884
The GNU wget utility will do this

Install and then put this command like this  in your cron

wget -O /tmp/out.txt  "¶m2=xyz"

LVL 62

Expert Comment

ID: 20330184
Why don't you schedule SQL statements from cron script? Fetching webpage introduces more moving parts in machine.
LVL 40

Assisted Solution

omarfarid earned 200 total points
ID: 20332291

You may use wget as a crontab job to check your web page. You may have a script like the following, call it checkmypage

cd /path/to/mydir
if test $? -eq 0

The above script checks for the exit status of wget ($?)
I left the two sections with dots so that you put your own commands when successful or failure.

The script can be made executable and run as ccrontab job:

crontab -l > mycrontab

add the line below to mycrontab

0,10,20,30,40,50  * * * * /path/to/checkmypage

resubmit your cronjobs

crontab mycrontab


Assisted Solution

estrelow earned 50 total points
ID: 20338387
An alternative to wget is using lwp-request.
Just set:


Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
either24  challenge 19 97
haveThree challenge 22 118
Write an app 10 70
x-bar in Google Sheets 2 55
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question