linux - How do I kill a php script from another php script? -
i kill php script, script a.php, (while running) inside php script script b.php. when script a.php starts save kind of id database. when script b.php starts running want id database , use exit or kill script a.php inmediately.
is possible, , how can that?
update 1
there can multiple instances of a.php in case want kill single instance of a.php. can process id @ beginning of each script , save either in database or session variable b.php knows a.php script kill.
this application used within backend program of website. reason killing scripts a.php because users click on many buttons trigger a.php run. a.php takes around 5 seconds run , latest version of a.php required kill other a.php scripts still running save server resources not interesting in outcome anymore.
to kill scripta.php scriptb.php must able execude system commands, , should not running within webserver.
you store pid of scripta.php within database. use getmypid(). in scriptb.php use system() function kill other process:
system("kill $pidofscripta");
Comments
Post a Comment