LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 09-25-2004, 08:48 AM   #1
linux_pioneer
Member
 
Registered: May 2003
Distribution: Solaris 10, Solaris 8.0, Fedora Core 3
Posts: 203

Rep: Reputation: 30
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.
 
Old 09-25-2004, 11:10 AM   #2
lappen
Member
 
Registered: Aug 2003
Location: Sweden
Distribution: Slackware 9.1 / Gentoo
Posts: 83

Rep: Reputation: 15
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
 
Old 09-25-2004, 11:51 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
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...
 
Old 09-25-2004, 08:41 PM   #4
linux_pioneer
Member
 
Registered: May 2003
Distribution: Solaris 10, Solaris 8.0, Fedora Core 3
Posts: 203

Original Poster
Rep: Reputation: 30
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.
 
Old 09-26-2004, 06:52 AM   #5
lappen
Member
 
Registered: Aug 2003
Location: Sweden
Distribution: Slackware 9.1 / Gentoo
Posts: 83

Rep: Reputation: 15
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.
 
Old 09-26-2004, 01:22 PM   #6
DeTHZiT
LQ Newbie
 
Registered: Aug 2003
Location: Montreal, Quebec
Distribution: Gentoo, Slackware 9.1
Posts: 11

Rep: Reputation: 0
AFAICS: As Far As I Can See
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
php, else function not working. Erhnam Programming 4 06-01-2005 07:48 AM
Passing one php function result as a parameter to another php function davee Programming 13 09-12-2004 12:08 PM
Timed execution of a function arvind_tyche Programming 1 05-07-2004 08:25 AM
auto application(timed by day) running krome Mandriva 1 01-31-2004 04:21 PM
PHP - mail function saravanan1979 Programming 2 08-06-2003 01:46 AM


All times are GMT -5. The time now is 03:53 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration