Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I made a startup script to automatically start MySQL Daemon on startup. However, for some reason it's not working on a restart (but if I call it manually with the "start" option it works).
I used "who -r" to confirm my default run level is 5, and I put the script in /etc/init.d/mysqlds and I link to it from rc5.d with the name: S24mysqlds --> ../mysqlds
The only odd thing I can note is that when I run the script manually, it doesn't return to the command prompt until I hit the enter key. Any ideas why this isn't bringing up the mysql server on the restart?
Here's the script (my password replaced with asterisks). Maybe the problem is permissions. I set it to -rwx------ so the password is not readable, but I would have thought booting occurs with root privileges.
Code:
#!/bin/sh
#
case ${1} in
stop*)
/usr/bin/mysqladmin -u root --password=******** shutdown
;;
esac
case ${1} in
start*)
/usr/bin/mysqld_safe --user=mysql --log &
;;
esac
You only need one case statement. I don't think you want '*' after each option (I've never seen this). You also probably want to put double quotes around your ${1}. Also, why are you writing a script when one comes w/ mysql?
If this is an exercise in coding, I hope the above helps. If this is truly an attempt to automatically start/stop MySQL, then you really should use the script they provide.
HTH
Forrest
p.s. I didn't mean to imply that the '*' in a case statement wasn't valid, only that you don't need to match on start* and stop*.
Last edited by forrestt; 09-21-2009 at 01:13 PM.
Reason: added p.s.
The echo line was copied directly from the mysql.server script on my system (and then the other options were then removed), but the line works on my system even with the $ (although I don't know if it was put there on purpose or not. Also, I know the { and } are unnecessary, but they follow the style that the OP was using for variable referencing (and is my preference as well, although I didn't change the $0 to ${0} in the copied line).
Forrest
p.s. on further examination (I got curious), I've noticed that most of the "Usage" lines in my /etc/init.d scripts are 'echo $"Usage:...'.
Last edited by forrestt; 09-21-2009 at 01:46 PM.
Reason: added the p.s.
p.s. on further examination (I got curious), I've noticed that most of the "Usage" lines in my /etc/init.d scripts are 'echo $"Usage:...'.
Thanks for the info Just looked it up and found it's a locale feature: "Bash supports the $"..." quoting syntax to do locale-specific translation of the characters between the double quotes.". Always something new to learn about bash!
Glad you pointed that out cause I've been hitting Google pretty hard w/ all kinds of 'bash echo $""' type queries (along w/ pounding my head on my desk).
Glad you pointed that out cause I've been hitting Google pretty hard w/ all kinds of 'bash echo $""' type queries
Yeah -- that's a hard thing to Google for! I started out guessing it might be a sh backwards compatibility thing so checked the bash reference for bash/sh differences and got lucky!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.