Completing another user script

In the linux window, I have a python script that always ran from a predefined user. It may take some time to complete this, so I want to allow other users to stop it from the Internet.

Using kill fails if the operation is not allowed.

Can I somehow modify my long python script so that it receives a signal from another user? Obviously, another user is starting the web server.

Maybe there is a completely different way to approach this problem, which I can’t think about right now.

+3
source share
4 answers

python script deamon ( Unix Daemon) ( ), apache init.d script , php-, ( - script - 'otto2'):

<? 
$otto = "/usr/etc/init.d/otto2 "; 

if( $_GET["action"] ) { 
    $ret = shell_exec( $otto.$_GET["action"] ); 
    //Check your ret value  
} 
else { 
    ?> 
    <a href="<?=$PHP_SELF?>?action=start">Start  </a> 
    <a href="<?=$PHP_SELF?>?action=stop">Stop  </a> 
    <? 
} 

?>

, " ":)

+1

kill , script. . , .

'kill', script, - , script.

+1

script . , script N - (, , -).

, , .

+1

sudo kill root, .

How about a long-running script checking a condition every x seconds, such as the existence of a file of type /tmp/stop-xyz.txt? If this file is found, the script exits immediately.

(Or any other means of interprocess communication - it does not matter.)

0
source

Source: https://habr.com/ru/post/1755307/


All Articles