LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-27-2006, 02:22 PM   #1
kklein9
LQ Newbie
 
Registered: Dec 2004
Location: Lexington, ky
Distribution: redhat fc2
Posts: 4

Rep: Reputation: 0
Question 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
 
Old 01-27-2006, 02:28 PM   #2
darksmiley
Member
 
Registered: Jan 2004
Location: London, England
Distribution: Usually Linux Mint, Debian, Ubuntu or CentOS
Posts: 233

Rep: Reputation: 30
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 =)
 
Old 01-27-2006, 03:08 PM   #3
Brian1
Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 61
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
 
Old 01-27-2006, 03:32 PM   #4
cmfarley19
Member
 
Registered: Nov 2002
Location: Central VA
Distribution: Ubuntu/Debian
Posts: 228

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

Hope it helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 02:53 AM
startup and shutdown script android6011 Slackware 3 11-03-2005 04:04 PM
get a script to run on startup kram Debian 3 04-23-2005 02:23 PM
Run a script at startup iain.ross Linux - Newbie 8 08-27-2004 04:03 PM
How to run script on startup Angelis Linux - General 1 11-16-2003 05:45 AM


All times are GMT -5. The time now is 06:18 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration