Solved

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

Posted on 2007-11-21
5
1,049 Views
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 http://mydomain.com/sqlop.php?param1=123¶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?
0
Comment
Question by:bemara57
5 Comments
 
LVL 2

Assisted Solution

by:overflow34
overflow34 earned 50 total points
ID: 20329777
http://forum.powweb.com/archive/index.php/t-13524.html

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

Accepted Solution

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

http://www.gnu.org/software/wget/

Install and then put this command like this  in your cron

wget -O /tmp/out.txt  "http://mydomain.com/sqlop.php?param1=123¶m2=xyz"

0
 
LVL 61

Expert Comment

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

Assisted Solution

by:omarfarid
omarfarid earned 200 total points
ID: 20332291
Hi,

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
/path/to/wget www.mydomain.com
if test $? -eq 0
then
.
.
.
else
.
.
.
fi

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

0
 
LVL 1

Assisted Solution

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

lwp-request http://mydomain.com/sqlop.php?param1=123¶m2=xyz
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
has22 challenge 11 78
either24  challenge 19 90
Write an app 10 66
Change to event 1 100
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now