vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Executing php script every 30 seconds? (https://vborg.vbsupport.ru/showthread.php?t=298632)

bzcomputers 06-01-2013 04:40 PM

Executing php script every 30 seconds?
 
I currently have the following code in in a custom page which works fine executing a php script.

Code:

exec('php -q /path/to/file/getImage.php');
The php that is being executed saves an image to the server.


What I'm trying to do is get this to execute every 30 seconds while the page is loaded.


I've tried something like this, but it wouldn't work.


Code:

<script type="text/javascript">
jQuery(document).ready(function() { 

  setInterval(function() {
    jQuery.get('/path/to/file/getImage.php');
  }, 30000);
});
</script>


snakes1100 06-01-2013 05:29 PM

Add it to a cron

0,30 * * * * /path/to/php /path/to/file/getImage.php

kh99 06-01-2013 05:29 PM

It depends on how your server is configured, but the path to the file that you'd use in the exec command usually isn't the same as what you'd use while requesting it via http (which is what a jquery get() does).

I don't understand why in the first code you posted you're using exec(), but in the javascript you're calling getImage.php directly (I'm not saying it's wrong, I'm just curious).

ETA:...or use cron like snakes says above. :)

snakes1100 06-01-2013 05:32 PM

looks like i beat by sec's lol

bzcomputers 06-01-2013 07:49 PM

Edit:
......original code ended up working, the issue was the php I was trying to call was outside the public root and it wouldn't execute from the vB template from there (but it would from the main .php). Moved the php into a public directory and it worked.


All times are GMT. The time now is 08:01 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.01072 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
  • (2)bbcode_code_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