Boot/Shutdown scripts

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Boot/Shutdown scripts
# 1  
Old 05-23-2013
Boot/Shutdown scripts

Server: Redhat 6.2
Goal: Startup script/Shutdown Script
Overview: I'm just doing a very basic test. I'm not getting chkconfig involved.
Research so far: I've found a few different ways of getting this to work, some say I can just drop the scripts in the corresponding rc directory. Others recommend dropping the scripts /etc/init and using chkconfig to create the symlinks and manage them as services. Eventually I want to get to the chkconfig level but right now I just want two scripts, one for startup and one for shutdown. I haven't been able to get any of the methods I've found to work so I decided to start as small as possible and build up from there.


Steps so far:
Two files:
Code:
#cat /etc/rc3.d/S98test
echo "Starting rc3 test" > /tmp/rc3starttest

and

Code:
#cat /etc/rc3.d/K01test
touch /var/lock/subsys/K01test
echo "Stopping rc3 test" > /tmp/rc3stoptest

inittab is set for runlevel 3.

I'm probably violating so many standards this way. I just wanted a very very low level test for startup/shutdown scripts. S98test runs fine, on reboot the file is in /tmp. K01test seems to be doing nothing. After reboot there is no file in /tmp.
# 2  
Old 05-23-2013
Is there a question in there somewhere?
# 3  
Old 05-23-2013
Quote:
Originally Posted by HayekSplosives1
I'm probably violating so many standards this way. I just wanted a very very low level test for startup/shutdown scripts. S98test runs fine, on reboot the file is in /tmp. K01test seems to be doing nothing. After reboot there is no file in /tmp.
The stop script is not working
# 4  
Old 05-24-2013
lock files are removed during a restart / shutdown. Given that a lock file must exist before a Kill script is run, creating it in the Kill script is pointless when entering any runlevel from a restart. Your file would be created, however, if you switched to runlevel 3 from either single user mode (init 1) or X (init 5).

Code:
(start VM)
[root@test1 tmp]# ll /tmp/rc3*
-rw-r--r--. 1 root root 18 May 16 13:49 /tmp/rc3starttest
[root@test1 tmp]# init 1
[root@test1 tmp]# init 3
[root@test1 tmp]# ll /tmp/rc3*
-rw-r--r--. 1 root root 18 May 16 13:49 /tmp/rc3starttest
-rw-r--r--. 1 root root 18 May 16 13:51 /tmp/rc3stoptest

The Kill script should go at the runlevel you expect to enter when switching to a new runlevel (i.e. shutdown (0), reboot (6) or back to 3 from single user mode (1) or X (5)) as said. It usually doesn't make sense to have the start and stop scripts at the same runlevel, since why would you want to stop something before you started it?

Last edited by Scott; 05-24-2013 at 05:11 AM.. Reason: Rewording
This User Gave Thanks to Scott For This Post:
# 5  
Old 05-24-2013
Ahhh very nice.

I put myself in a Catch-22 of sorts. That helps clarify many many things. Thanks Scott
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Boot/Shutdown script automation

Looking to automate some commands to run at boot and poweroff in a startup/shutdown script. How do I place it on the system so that it will be run automatically? I don't want to use cron, not quite specific enough, random times when I may boot or shutdown. ---------- Post updated at 10:47 PM... (8 Replies)
Discussion started by: 3therk1ll
8 Replies

2. Shell Programming and Scripting

Oracle DB Start shutdown scripts

Hi, We have a requirement wherein we do not want to share the Oracle DB sys and system passwords to be shared with the support desk. But they will be responsible for starting/shuting down the Database. Is it possible to write a shell script which will read the sys and system passwords from a... (0 Replies)
Discussion started by: narayanv
0 Replies

3. UNIX for Advanced & Expert Users

Solaris shutdown and boot history

Hello. I'm trying to get a Solaris (SunOS 5.10) shutdown and boot history. Unfortunately the /var/adm/wtmpx file does not cover the period I want to trace. It's been reset. Therefore the command, "last" (or "last reboot") does not reach back far enough. Additionally the /var/adm/messages*... (4 Replies)
Discussion started by: etlpkby
4 Replies

4. AIX

Please update inittab/rc.shutdown/rc scripts to start/stop mqm (need help Urgent)

HI i need help from seniors on this issue, i need to know how to do this, i need to update 50+ server starting saturday. below is the ticket which i have with full description. Currently MQ Series must be stopped before and started after any reboot. Not having the start/stop as part of... (2 Replies)
Discussion started by: gulamibrahim
2 Replies

5. AIX

Startup/shutdown scripts in AIX

hi, If we place Sxx (startup script) and Kxx(shutdown script) in /etc/rc.d/rc2.d,then it would start and stop automatically(assume they are linked to other script that actually starts/stops). is there really a link needed here to /etc/rc.d/init.d? if not,what is the use of this directory..?... (1 Reply)
Discussion started by: to_bsr
1 Replies

6. UNIX for Dummies Questions & Answers

Boot scripts?

Hello, I am new to Solaris. I have installed a Solaris 10.0. As default its shell is sh (#) and I want to modify boot records of my Solaris. I want to run some shell scripts, change shell, change PATH environment and similiar things after boot automaticially. I don't know which files are read... (1 Reply)
Discussion started by: XNOR
1 Replies

7. AIX

Startup/Shutdown scripts

I understand that by putting in entries into the /etc/inittab file. We can actually call the our scripts during startup. mkitab "start_server:2:once:sh /scripts/startserver.sh" Would the system wait for startserver.sh finish executing before it goes to another entry? and how long would it... (1 Reply)
Discussion started by: vincente
1 Replies

8. SuSE

Shutdown scripts

Hello all I'm trying to automate the startup/shutdown of my database whenever the OS is bounced ... OS : Linux (Kernel : 2.4.20.-6) Oracle : 9.2.0.5 The contents of /etc/init.d/dbora file is listed below case "$1" in 'start') su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart"... (1 Reply)
Discussion started by: luft
1 Replies

9. Shell Programming and Scripting

Shutdown Scripts

Hi, Recently I've created a script to shutdown a few hpux workstations and I found out that the script can only shutdown 1 workstation and then exit out from the loop without shutting down the rest of the workstation. The scripts is as below (brief one): hcp_list="machine_a ... (4 Replies)
Discussion started by: zheng_soon
4 Replies

10. UNIX for Advanced & Expert Users

rc scripts, do i need to kill them on shutdown?

We have a bunch of tools, that run on linux and on unix, I've got start up scripts that bring up their license managers when the unix box boots, do I need kill scripts for when the box is shutting down? I've not seen much documentation on this, just on getting the license managers started, but... (1 Reply)
Discussion started by: kymberm
1 Replies
Login or Register to Ask a Question