PHP script that for an operating system service

Asked

Viewed 349 times

0

someone knows if there is a command in php or script that stops a service in the operating system ?

1 answer

1


You can use the command exec, and execute a killall -9 [nome_do_processo]

<?php
    exec("killall -9 mysql"); // mysql, por exemplo
<?
  • Hmm cool I’ll try here Thanks !

  • Rafael, I can for example in place of killall -9 put other commands, such as stopping apache by Centos, exec("sudo service httpd stop"); ??

  • exec serves exactly for you to execute commands as if you were in a terminal. So, feel free. Thinking now, I just don’t know how the script will handle permission, unless you run PHP script with sudo.

  • Cool Rafael, I’ll take a look here, anyway thanks guy ..

  • =) good luck! You’re welcome!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.