Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-25-2004, 08:48 AM
|
#1
|
Member
Registered: May 2003
Distribution: Solaris 10, Solaris 8.0, Fedora Core 3
Posts: 203
Rep:
|
Running a PHP function at timed intervals
I have a web database where I use PHP to query the database and display results. I would like to run a query every few minutes to check for updates. (The database is updated constantly by network management agents). Is there a way for me to run a PHP function at so many intervals without using auto-refresh? With java I've used settimeout() function to update seconds for a clock. Is there a similar method for PHP? I could do an auto refresh for the entire page but I'd rather not.
|
|
|
09-25-2004, 11:10 AM
|
#2
|
Member
Registered: Aug 2003
Location: Sweden
Posts: 83
Rep:
|
I think cron would do the job here,
Just add it to your crontab and what script to run at what intervals through php cli
|
|
|
09-25-2004, 11:51 AM
|
#3
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep: 
|
Quote:
I could do an auto refresh for the entire page but I'd rather not.
|
AFAICS, that will be the only way, I'm afraid...
|
|
|
09-25-2004, 08:41 PM
|
#4
|
Member
Registered: May 2003
Distribution: Solaris 10, Solaris 8.0, Fedora Core 3
Posts: 203
Original Poster
Rep:
|
lappan: I don't think I need to use a crontab. I want to run this script within the webpage every so minutes. The intent is to have the end user see updates in the database without using screen refresh.
Hko: What does AFAICS mean? I understand PHP does not do event handling as Java does. Had to ask. Also I was considering using Javascript to run that query. I've done some research online and all seems to point to JSP. I don't really need server side scripting for this function. I've created a java program that can query my database with JDBC. I can't seem to incorperate this program as a script embedded in my web page. Perhaps I need to open this as a whole other topic.
|
|
|
09-26-2004, 06:52 AM
|
#5
|
Member
Registered: Aug 2003
Location: Sweden
Posts: 83
Rep:
|
What about meta tags?
Code:
Meta Refresh tag
The Refresh meta tag will automatically send users to another URL, after a specified amount of time has elapsed. The syntax for the content part is...
the number of seconds to delay, then a semicolon, then the new destination URL.
For example...
<meta http-equiv="refresh" content="5;URL=http://www.site.com/">
Note that the search engines don't like Meta Refresh tag and either ignore the current page and index the second page or may not index the site at all.
Can't see why it wouldn't work to send the person back to the same page again and if I remember correctly php should have a function for grabbing the current location and send it back
Last edited by lappen; 09-26-2004 at 06:56 AM.
|
|
|
09-26-2004, 01:22 PM
|
#6
|
LQ Newbie
Registered: Aug 2003
Location: Montreal, Quebec
Distribution: Gentoo, Slackware 9.1
Posts: 11
Rep:
|
AFAICS: As Far As I Can See
|
|
|
All times are GMT -5. The time now is 12:04 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|