i want to monitor, stop and stop a service. but cant get a clue hot to do that.

the monitor is ok by using this code:
<pre><p></p>
<span class="style1"><b>Service asterisk:</b> </span>
<?php system("/var/www/html/cam/mysql.sh"); ?></br>

</pre>

and in the file services.sh
service mysql status

i have also use:
<?php
$mysql = shell_exec('service mysqld stop');
echo "<pre>$mysql</pre>";
?>

but i am getting the error below:
================================
Stopping MySQL: [FAILED]
=======================================


but how to include a start and stop button and make it work.


thanks in advance

Hello,

Well you are running into a couple of things that you really need to think about. The security in the server is such that users from the internet should not be able to start and stop services on the server. If you can start and stop it anybody can. You would have to do it from mysqladmin and you would need the root mysql password.

If you don't mind me asking why do you need to stop and start the service from a web page?

that's because sometimes MySQL services freezes.i need to stop and start it again.
am trying to write a php system to do that, so that my client can do it by themselves. no need for me to intervene.

Hello,

OK your call. It is unusual for mysql to just freeze. Have you looked at the logs to see what is causing it. I run multiple web servers that have not had mysql restarted in over a year.
In any event you need to do a system call and run

mysqladmin stop -u root -p

and have them enter the mysql root password when prompted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.