Jump to content

running long running script in shared hosting


csplrj

Recommended Posts

I have a long running script which may go on for long time may be 4 to 5 hours?

How to get running the same in a shared hosting environment?

 

As I tried the same but it seems it does not works in a shared hosting environment?

 

I tried

set_time_limit(0);

ignore_user_abort();

 

but it does not seems to works

 

Thanks in advance

 

CSJakharia

If your host doesn't support cron, try something like this:

<?php
session_start();
$timer = 5;
$refresh = $_SERVER['REQUEST_TIME'] + $timer;


while (1) {
if (time() >= $refresh) {
	die('<meta http-equiv="refresh" content="0">');
} else {
	//Execute code
}
}
?>

 

 

Here's an example of something that you could do:

<?php
session_start();
$timer = 5;
$refresh = $_SERVER['REQUEST_TIME'] + $timer;

if (!isset($_SESSION['i'])) {
$_SESSION['i'] = 0;
}

while (1) {
if (time() >= $refresh) {
	die('<meta http-equiv="refresh" content="0">' . $_SESSION['i']);
} else {
	$_SESSION['i']++;
}
}
?>

 

Code above counts, saves as a session variable, refreshes every five seconds, and starts where it left off. What exactly are you trying to do?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.