Click to See Complete Forum and Search --> : kill/restart script? need help on one line..


SKoL
09-12-2001, 09:35 PM
Sup guys, Need some help.

I've got MySQL and apache running. In case one of them dies, I wrote a script to restart it.

Problem is, (as we all know) MySQL has the safe_mysqld action to try to keep MySQL from totally dying. I need the script to kill the PID of safe_mysqld then restart it using another script i have, here is it so far.



#
#This is where I need all mysqld to be #killed then restart mysql using the ./ci-#mysqlserver start script
#
#
if !(ps -u root | grep safe_mysqld); then
/usr/local/courseinfo/tools/./ci-mysqlserver start
fi
#
#
#This bottom part is fine, it restarts #apache fine
#
#for httpd
if !(ps -u ciuser | grep httpd); then
/usr/local/courseinfo/tools/./ci-httpdserver restart
fi


thanks..

The Kooman
09-12-2001, 11:28 PM
Originally posted by SKoL:
<STRONG>Sup guys, Need some help.

I've got MySQL and apache running. In case one of them dies, I wrote a script to restart it.

Problem is, (as we all know) MySQL has the safe_mysqld action to try to keep MySQL from totally dying. I need the script to kill the PID of safe_mysqld then restart it using another script i have, here is it so far.



#
#This is where I need all mysqld to be #killed then restart mysql using the ./ci-#mysqlserver start script
#
#
if !(ps -u root | grep safe_mysqld); then
/usr/local/courseinfo/tools/./ci-mysqlserver start
fi
#
#
#This bottom part is fine, it restarts #apache fine
#
#for httpd
if !(ps -u ciuser | grep httpd); then
/usr/local/courseinfo/tools/./ci-httpdserver restart
fi


thanks..</STRONG>

Why not just?

#!/bin/bash
killall safe_mysqld
safe_mysqld


man killall for more.

BTW, why the '.' after '.../courseinfo/tools/' ?? Just curious!

SKoL
09-13-2001, 12:09 AM
Why not just?

#!/bin/bash
killall safe_mysqld
safe_mysqld


man killall for more.

BTW, why the '.' after '.../courseinfo/tools/' ?? Just curious![/QB]


That right there kills it and restarts it. If the DB dies I want it to then do that..

The current script tries to execute, and it can't because safe_mysqld is still alive, even when the acual db thread isn't. (which is annoying and makes my script useless)

Not sure what else to do..