LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How do I start up a shell script when the system starts? (https://www.linuxquestions.org/questions/programming-9/how-do-i-start-up-a-shell-script-when-the-system-starts-792346/)

resetreset 03-01-2010 09:40 AM

How do I start up a shell script when the system starts?
 
This is on Fedora 11.


Thanks.

paulsm4 03-01-2010 09:47 AM

Edit /etc/rc.d/rc.local

kilgoretrout 03-01-2010 09:51 AM

The easiest way is to stick the script in /etc/rc.d/rc.local. Other that that, you put your script in /etc/rc.d/init.d and make the appropriate links to the runlevels you want the script to run in by liniking the script to the appropriate /etc/rc.d/rc*.d directory.

resetreset 03-01-2010 09:57 AM

Er - what do I do if I want it run in ALL runlevels?


Which runlevel does Fedora normally boot to anwyay?

cdbunch 03-01-2010 10:03 AM

There are a number of places where that can be done. The right place to do it depends a lot on what the script is supposed to accomplish. If you could clarify that it would make it easier to give a good answer.

If what you want to do is something along the lines of starting up a service process then putting a properly structured script in /etc/init.d and setting up the appropriate links to it with chkconfig could be an option. Then you could specify which run levels you want the script to be executed for.

Another option is running it from /etc/rc.d/rc.local which is intended for system customization and runs after the /etc/init.d scripts. This may be important if your script is going to depend on something that the system startup scripts have launched.

Also, I assume you want it to start during boot up. If you wanted it to start on login that would be done differently.

Cameron Bunch

kilgoretrout 03-01-2010 10:27 AM

Here's a nice overview of the RH/Fedora init process and configuration:

http://www.chinalinuxpub.com/doc/www.../runlevels.htm

For a GUI desktop, fedora normally boots to runlevel 5. For a text login like you typically have on a server, fedora boots to runlevel 3. As noted above, we need more details about what exactly you want to accomplish. Scripts launched from rc.local or init.d run with root privileges which may not be what you want.

resetreset 03-01-2010 11:32 AM

I wanted to know this for just a hypothetical case - my friend needs to maybe disable his USB port sometimes while booting.

And yeah, I know about .bash_profile :) Thanks for offering to help anyway.


All times are GMT -5. The time now is 05:00 PM.