Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/150892-solved-php-refresh-page/
Share on other sites

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.

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.