通过按钮单击在PHP中使用killall命令

I am looking to have a button on a webpage that I can use to kill all of the node processes that are running. I have got it working fine from terminal on Mac OS by using sudo killall node, but when i have tried to create a button from the website I am getting the error 'No matching processes belonging to you were found'. My code is,

<?php
 if (isset($_POST['button'])) { exec('/usr/bin/ sudo killall node'); } ?>
 <form method="POST">
<p>
    <input type="hidden" name="button" value="1">
    <input type="submit" value="Stop">
</p>
</form>

I am guessing it is because I need to type in a password for sudo is why it won't work on the webpage. Is there a way around this or another option for doing it? thanks..

the user running php has probably not the privileges to run command with sudo ( or at least he can't enter the password )

if you really want to give php the right to run this command you have to figure out which user is running php (echo `whoami`;) and then give him the right to run this command without asking for a password, run sudo visudo to edit sudo configuration

in it, add the following line at the end of the file:

your_php_user ALL = (root) NOPASSWD: /usr/bin/killall node

note: you have a space between /usr/bin/ and sudo