LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to run a script at startup after a shutdown? (https://www.linuxquestions.org/questions/linux-software-2/how-to-run-a-script-at-startup-after-a-shutdown-408679/)

kklein9 01-27-2006 02:22 PM

How to run a script at startup after a shutdown?
 
I have this script:

ken@uptime:~> cat /etc/rc.local
/etc/init.d/uptime_db start &
/etc/init.d/uptmd_sh start &
/opt/tivoli/tsm/client/ba/bin/dsm.sh start &
echo 'started uptime and tsm client'

I want it to run every time I startup. Right now I can run it by hand. I thought it should go in /etc/rc.local, but that didn't work. I tried putting it in /etc/rc, but that doesn't work either.

TIA

darksmiley 01-27-2006 02:28 PM

i think there a few rc. files that are run at startup... all at slightly different times. rc.S is a big one I think, but it is run very early on. rc.5 or rc.4 are good as well if you want it run later (as they are run when entering runlevels 4 and 5 respectively). and that's about all I know! sorry I can't be of more help, but lots of them are run on boot so experiment =)

Brian1 01-27-2006 03:08 PM

You might need to pause between the commands before the next starts. You can use the ' sleep ' command usually in /bin or the universal pause statement ' ping -c2 127.0.0.1 > /dev/null '

Also if thats all thats in your /etc/rc.local then it needs one line at the very beginning to define it as a script to use a shell of some type. Even though it is remarked with a ' # ' it still defines the shell it uses. It needs to have this ' #!/bin/sh '. Also needs to be executable. ' chmod + x /etc/rc.local '. Must be run as root.

Example: ken@uptime:~> cat /etc/rc.local
#!/bin/sh
/etc/init.d/uptime_db start &
/etc/init.d/uptmd_sh start &
/opt/tivoli/tsm/client/ba/bin/dsm.sh start &
echo 'started uptime and tsm client'


Examples with pause statements.

ken@uptime:~> cat /etc/rc.local
#!/bin/sh
/etc/init.d/uptime_db start &
/bin/sleep 2
/etc/init.d/uptmd_sh start &
/bin/sleep 2
/opt/tivoli/tsm/client/ba/bin/dsm.sh start &
echo 'started uptime and tsm client'

or
ken@uptime:~> cat /etc/rc.local
#!/bin/sh
/etc/init.d/uptime_db start &
ping -c2 127.0.0.1 > /dev/null
/etc/init.d/uptmd_sh start &
ping -c2 127.0.0.1 > /dev/null
/opt/tivoli/tsm/client/ba/bin/dsm.sh start &
echo 'started uptime and tsm client'

See if any of this helps.
Brian1

cmfarley19 01-27-2006 03:32 PM

Check this out...
http://farley.no-ip.org/linux/daemon-boot.php

Hope it helps.


All times are GMT -5. The time now is 09:25 AM.