- Code: Select all
#=== XAMP part of code
/Applications/XAMPP/xamppfiles/xampp startmysql >/dev/null
/Applications/XAMPP/xamppfiles/bin/mysql -u root -h localhost sugar < /users/al/documents/sugar.bak
/Applications/XAMPP/xamppfiles/xampp stopmysql >/dev/null
Is there a way to determine if MySQL is already running, and if so, do not try to start it OR stop it? Anyone here a bash scripting guru?
Why do I want to do this? Sometimes I'm running XMAP when this backup procedure starts and I don't want to close MySQL if it was running before the script started. Trying to start is while running is no problem. But closing it while I'm using it in the foreground is not good. So I want to do a simple status check and not open or close it if it is already going. I run this script five or six times a day... sometimes I've got XAMP open... sometimes not. If the script runs when I'm working on XAMPP and it closes MySQL, boy to I get a ton of errors on the next database read or write!! It wakes you up quickly!! (Of course all I have to do is turn it back on with the XAMPP control... but it would be nice not to have to.)