My Project is Lighting Control on Rasp Pi by use Rasp Pi as Web Server & Control the light by python script I use the UI on PHP Website to control the light
Here is my php code
<?php
public function auto1()
{
system('sudo -u root -S python /var/www/4led/chktime1.py');
}
public function disauto1()
{
system('echo raspberry | sudo -u root -S pkill -f chktime1.py');
}
?>
when I press the on button on website to turn auto script It call auto1 and work correctly but this is loop script (I intend to make it loop alltime) but when I press the off button It can't close it because the loop of chktime1.py is still working and cannot open other script or command in disauto1. How can I stop this script from PHP command.
Thank you for your helping