LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How do I make a command run as root at boot up under Fedora 3? (http://www.linuxquestions.org/questions/linux-software-2/how-do-i-make-a-command-run-as-root-at-boot-up-under-fedora-3-a-288593/)

versaulis 02-10-2005 01:54 PM

How do I make a command run as root at boot up under Fedora 3?
 
I have a file that looks like this:

Code:

#!/bin/bash

/usr/local/mysql/bin/mysqld_safe --user=mysql &


and I want it to run at boot as root user. I tried putting it in /etc/rc.d/init.d but that didn't work. I figured I better ask you guys where the proper place for it is since lots of people ask me questions about linux and I don't have to tell them somthing improper if I can help it anyway.

Thanks, guys.

coureyv 02-10-2005 02:09 PM

you see /etc/init.d/rc5.d into the scripts when you go in init 5 when normal mysql is already runniin ?
cxy

versaulis 02-10-2005 02:36 PM

Quote:

Originally posted by coureyv
you see /etc/init.d/rc5.d into the scripts when you go in init 5 when normal mysql is already runniin ?
cxy


I don't understand what you said here. I don't know what all the rc#.d folders do... only have clues. I know they cause things to start up at boot. MySQL doesn't run until I start it up with the command shown above. I don't understand how I can "see" anything going though any init stage.

coureyv 02-10-2005 02:43 PM

easy, /etc/init.d/rc(i).d are directories where scripts are executed for init level 1 rc1.d, ... init level 5 rc5.d
At this stage if you want to run at boot a script you place it in the good level into an existing script or (more complex) you create your personnal script. Good luck

versaulis 02-10-2005 03:02 PM

How do I create my own script? I've wented to know how to do that for a while. I think I'm ready to take that on.

jschiwal 02-10-2005 06:22 PM

There most likely is a mysql script in /etc/init.d but you don't have it selected to start at boot up. Does the command 'service mysql start' or 'service mysqld start' bring up the service. You could use the 'chkconfig' command as root to start the mysql daemon to start when you boot up.
chkconfig --list will print out a table of services and the runlevels they start in. It also gives the instructions to use to start a service on a certain run level. You probably want to start 'mysqld' under runlevels 3 and 5. There may be a second related service, but I'm not at my linux box to check. 'info mysql' may give more information.

Here is a skeleton InitV script for redhat:
http://lightconsulting.com/~thalakan/rhsysv-skeleton
If you notice the comment line in the script:# chkconfig: 2345 55 25
This line is used by chkconfig, so your script needs it. In other words, this is more than a comment line.

The scripts in /etc/init.d/ are linked to /etc/rc.d/rc.3 for example.
The number after 'rc.' is the run level where these scripts will start.
Scripts beginning with the letter 'S' are started during boot up in alphabetical order. Scripts starting with the letter 'K' are run during shutdown. Again, these are links to the scripts in /etc/init.d (same as /etc/rc.d/init.d, i.e. one directory location is a symbolic link to the other. )

There is also an /etc/rc.d/rc.local script that will run after the rc.d scripts run. However for the mysql server, you probably want to use the script that the system runs in /etc/init.d/ .

There may be a red hat gui'd equivalent to the 'chkconfig' program, for starting services.

Good Luck!


All times are GMT -5. The time now is 11:43 AM.