Niccaman Posted March 24, 2009 Share Posted March 24, 2009 I am trying to run a cron job every 10 seconds, but my host provider says no more often than 15 minutes. So what i need is a php that will refresh it self. (Also if anyone knows, will a cron job execute javascript?). What i added at the end of my page was this: $page = "/serverprocess.php"; $sec = "10"; header("Refresh: $sec; url=$page"); Nothing happens. The page never reloads. This page doesn't echo or print anything, so why not? is header blocked by cron jobs? any solutions to my problem of needing to run this code multiple times with a timeout feature? perhaps javascript? Quote Link to comment https://forums.phpfreaks.com/topic/150892-solved-php-refresh-page/ Share on other sites More sharing options...
ober Posted March 24, 2009 Share Posted March 24, 2009 Cron is server side. It cannot execute JS, which is client side. Without cron, you cannot schedule a page to be executed on a specific interval. The only way to do this is with a meta-refresh or a JS timeout, both of which require a browser to be open all the time. Quote Link to comment https://forums.phpfreaks.com/topic/150892-solved-php-refresh-page/#findComment-792737 Share on other sites More sharing options...
Niccaman Posted March 24, 2009 Author Share Posted March 24, 2009 So, what your saying is there is no solution to my problem? Do u know whether or not it is possible to use a header w/ timout solution with cron? can you think of any other php functions that can achieve this goal? Perhaps i simply copy the same code multiple times in one page. How would i be able to make sure there was a time delay in between two sets of code? any ideas? Thanks in advance for your responses. Quote Link to comment https://forums.phpfreaks.com/topic/150892-solved-php-refresh-page/#findComment-792931 Share on other sites More sharing options...
wildteen88 Posted March 24, 2009 Share Posted March 24, 2009 Not sure but maybe you could place your code within an infinty loop then add a sleep function, which will have the affect of running your script every ten seconds, example while(true) { // place your code here // pause script for 10 secounds sleep(10); } However for this to work you'll need to set max_execution_time to 0. Quote Link to comment https://forums.phpfreaks.com/topic/150892-solved-php-refresh-page/#findComment-792940 Share on other sites More sharing options...
Niccaman Posted March 24, 2009 Author Share Posted March 24, 2009 That worked brilliantly. Exactly what i needed...Exactly why i love these forums. Thanks a bundle. Quote Link to comment https://forums.phpfreaks.com/topic/150892-solved-php-refresh-page/#findComment-792975 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.