Litespeed and unlimited time in cron jobs (PHP scripts)

ShinJii

Verified User
Joined
Mar 20, 2014
Messages
224
Hi,
I have big probem....
I have on server newest Alma Linux 8 and newest DA etc.
I need to have cron job script working more than 60 minutes.... it's not working like I need...script (PHP) in litespeed is ending after 60 minutes everytime.... I need to run it more than 60 minutes...
What I did and it's not working:
Cron job command in DA:
Code:
/usr/bin/lynx -dump https://domain.com/script.php > /dev/null 2>/dev/null &

Exec shell in that above PHP script:
PHP:
 shell_exec(escapeshellcmd('/usr/bin/nohup /usr/bin/lynx -dump ' . $domain . '/script2.php > /dev/null 2>&1 &'));
.htaccess in that Path where is that script.php and script2.php:
Code:
<IfModule Litespeed>
    RewriteEngine On
    RewriteRule ^/dir/script.php?$ - [E=noabort:1, E=noconntimeout:1]
    RewriteRule ^script.php?$ - [E=noabort:1, E=noconntimeout:1]
</IfModule>
Anyone have any idea why it's ending after 60 minutes?.... what I have to configure?
 
Last edited:
Hello,

While I don't have a solution on how to either make the script working the way you want, or making LiteSpeed not to drop the connection, I would rather suggest that you rewrite the script and crontask to run in CLI mode. If the suggested method is not an option for you then you might ask it on LiteSpeed forums. Or probably somebody else here has a solution you are looking for.
 
Hello,

While I don't have a solution on how to either make the script working you want, or making LiteSpeed not to drop the connection, I would rather suggest that you rewrite the script and crontask to run in CLI mode. If the suggested method is not an option for you then you might ask it on LiteSpeed forums. Or probably somebody else here has a solution you are looking for.
Yeap, CLI is not an option right now :P ok I have to go to litespeed forum....
 
could you trying with simple script to debug the issued.


like this.
Code:
<?php
ignore_user_abort(true);
set_time_limit(0);

$times = time();
sleep(7200);
file_put_contents(__DIR__ ."/success_curl.txt,  time() - $times);


also for lynx command, maybe there have timeout on running like curl, or wget

maybe trying put "-connect_timeout=7200" options to cmd line

Code:
lynx -dump -connect_timeout=7200 https//www.domain.com/script.php
 
Last edited:
could you trying with simple script to debug the issued.


like this.
Code:
<?php
ignore_user_abort(true);
set_time_limit(0);

$times = time();
sleep(7200);
file_put_contents(__DIR__ ."/success_curl.txt,  time() - $times);


also for lynx command, maybe there have timeout on running like curl, or wget

maybe trying put "-connect_timeout=7200" options to cmd line

Code:
lynx -dump -connect_timeout=7200 https//www.domain.com/script.php
But I have ignore_user_abort(true); in PHP script so I guess even if it's lynx it should be working...
That things with sleep(7200) - what for? :) if it's terminated after 60 minutes anyway :D
 
I'm writing on Litespeed forum... any solution is not working for me...they're talking to me it's "directadmin problem" ... you tell me it's "litespeed problem" .... what a stupid situation.... how to get it working? I tried more things than I wrote in my first post... nothing is working ;/
 
That things with sleep(7200) - what for? :) if it's terminated after 60 minutes anyway :D
It just for debugging, it will terminated after 60Min or 120Min.
We don't know how you coding, so just trying with simple code.
 
I don't know exactly, but usually I start from googling where service conf files are, or look for them in /etc /usr/local or directly from daemon config /etc/systemd/servicename
 
I'm writing on Litespeed forum... any solution is not working for me...they're talking to me it's "directadmin problem" ... you tell me it's "litespeed problem" .... what a stupid situation.... how to get it working? I tried more things than I wrote in my first post... nothing is working ;/

Never said it actually. There are too many things stay unknown yet. I hoped they could provide a solution. If not then you will need to dig into details. And if you want us to help you, then help us to understand your issue better.

First of all it is not clear what error you get. Does a script exit? A connection with a webserver timeouts? Closes? What you have in error logs? Error code? Error text?
 
Hello. Try setting the variable lsapi_backend_max_process_time 9600 in the file /etc/httpd/conf/extra/mod_lsapi.conf Helped us with a similar problem.

Sorry, did not notice that the topic is not about mod_lsapi for Apache
 
Last edited:
I found option "Connection Timeout (secs)" with 3600 value in Tuning menu in LiteSpeed admin... I changed it to 36000 and we will see if it helps... I'll let you know.
 
Never said it actually. There are too many things stay unknown yet. I hoped they could provide a solution. If not then you will need to dig into details. And if you want us to help you, then help us to understand your issue better.

First of all it is not clear what error you get. Does a script exit? A connection with a webserver timeouts? Closes? What you have in error logs? Error code? Error text?
I guess it timeouts because it can't exit at this point after 60 minutes, I have couple of thousands platforms and it timeouts after like ~200 platforms (60 minutes) so there's many more to do :D
Litespeed has even tutorial about that timeout in PHP but... nothing is working for me O_o
 
I don't have a LiteSpeed server for testing, I already read the article which you are referring to. If you need any further assistance on the matter kindly provide requested information. More details from logs are required.

Litespeed has even tutorial about that timeout in PHP but... nothing is working for me o_O
 
Ok I found it with LiteSpeed support. I leave here my solution (in my case):

Go to LiteSpeed admin and then Configuration -> Server -> PHP -> PHP Handler Defaults -> Edit -> Environment -> wrote here LSAPI_MAX_PROCESS_TIME=36000

I didn't know I have to write it in Environment Section in PHP section :D (.htaccess instructions etc. didn't work for me)
 
Back
Top