vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Execute PHP script every X seconds? (https://vborg.vbsupport.ru/showthread.php?t=202051)

m002.p 01-16-2009 09:49 PM

Execute PHP script every X seconds?
 
Hello everyone.

I have developed a rather complex script to query a gameserver which also makes checks on players within. However the issue I am having difficulty with is running the PHP script every X seconds.

I know of a simple way which works but doesnt seem too accurate when executing it for me.

Code:

$overall_time = 0;
while ($overall_time < 60) {  $overall_time +10= ; sleep(10);

// The script

}

So I want to ask those knowledgable coders out there the best way to run a script say every 5-10 seconds using possibly a 1 min CRON kick start?

Any help appreciated.

Matt

Dismounted 01-17-2009 10:43 AM

PHP Code:

for ($i 0$i 6; ++$i)
{
    
// script here
    
sleep(10);



m002.p 01-17-2009 07:41 PM

Hi Dismounted. Out of interest is this best and most reliable way to run a script every X seconds?

Thanks for your assistance.

Dismounted 01-18-2009 03:26 AM

Most reliable? Maybe not. The PHP script will still suffer from timeouts as defined in php.ini. The best way I can think of right now is to create a shell script that will sleep and run your PHP script (with a cron kicking it).

m002.p 01-20-2009 09:41 PM

Any idea then how to do it with Shell?

Your help is appreciated


All times are GMT. The time now is 04:45 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01014 seconds
  • Memory Usage 1,716KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete