I have a shell scipt and at some point I want to check if mysql is running and start it if it's not. I'm trying the following, but not having any luck:
set mysqlstatus = `sudo /opt/local/bin/mysqladmin5 ping`
if ["$mysqlstatus" != 'mysqld is alive']
then
sudo /opt/local/share/mysql5/mysql/mysql.server start
fi
Best Answer
The script
run-one
is your friend:More about
run-one
script:http://blog.dustinkirkland.com/2011/02/introducing-run-one-and-run-this-one.html
If you cannot install
run-one
for whatever reason,then copy the following code into a new file called
run-one
:To give execution permission:
Finally, use
./run-one
or set correctly yourPATH
environment variable to use it without giving the directory.