Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Config shutdown, Add a script at shutdown
mahtay
post Apr 6 2003, 10:58 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 6-April 03
Member No.: 636



Yes of course I'm a newbie, taking a class at collage using Redhat 7.2 to learn with. As a final project I wnat to write a script that will run when
automaticly when you shut down - I've written the script o.k. but search as I might I cant figure out how to link it to the shutdown procedure, is there a way?
Thanks
Go to the top of the page
 
+Quote Post
Corey
post Apr 7 2003, 08:11 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 1,254
Joined: 21-September 02
From: St John's, Newfoundland, Canada
Member No.: 3



Well, you can place the script inside of /etc/init.d/ directory, and make sure that it follows pretty much in line with the other scripts that are located in that directory (being that it handels the "start" "stop" "restart" "reload" parameters). From there, you need to install links in the proper runlevel directorys. If you look in /etc you should see the directorys: rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d and rc6.d. Each of these directorys contains scripts that either start or stop different services depending on what runlevel the system is moving to. Two examples of links can be something like the following:

[quote]
user@host:$ ls /etc/rc2.d
S90programX    K50programY
[/quote]

So lets break it down:

<S/K><n>Programname

S/K: Controls wether the services is starting or stopping during this runlevel. <S> Start <K> Stop.
n: Controls what order the script is run with reference to the other scripts in the directory
Programname: What is being run

So, if I wanted to run dhcp on init 2 (Runlevel 2) then I first make the script that was able to handel the start, stop, restart, reload parameters, store this file in /etc/init.d (and make it executable), then I would create a link to that file:

[quote]
ln -s /etc/init.d/dhcp /etc/rc2.d/S90dhcp
[/quote]

Now this script will run each time the computer hits runlevel two. Equally, you can make the script stop the service in runlevel 0 or 6. Here is a brief description on each runlevel:

[quote]
0 Halt
1 Single-user mode
2 Not used (user-definable)
3 Full multi-user mode
4 Not used (user-definable)
5 Full multi-user mode (with an X-based login screen)
6 Reboot
[/quote]


--------------------
Corey Quilliam
(former) Linuxhelp.ca Administrator
cquilliam-AT-gmail-dot-com

Want to help out Linuxhelp.net? Check out our Linuxhelp Wiki and see if there are some articles you would like to submit!!

--
Ubuntu 8.04 64-bit - Work Laptop (HP-Compaq NC6400 Core2)
Kubuntu 8.04 64-bit - Desktop (HP m8120n QuadCore)
Ubuntu 6.04 - Server (I'm not upgrading this baby until support runs out in 2012) (Some old POS dell)
Go to the top of the page
 
+Quote Post
mahtay
post Apr 8 2003, 09:07 AM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 6-April 03
Member No.: 636



Thank you very much for responding, you may have given me the key to my "A" from the class. From all of the reading I have done I was moving in the right direction but it didn't make sense to me as all of the directories seemed to have only to do with startup so even though I knew I was looking in the right areas I couldn't figure out where to put and where/how to link from.
Go to the top of the page
 
+Quote Post
Corey
post Apr 9 2003, 09:29 AM
Post #4


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 1,254
Joined: 21-September 02
From: St John's, Newfoundland, Canada
Member No.: 3



hrmm, i should have been a teacher.

and to think, when i go back to college next month, I got to do Introduction to Unix smile.gif


--------------------
Corey Quilliam
(former) Linuxhelp.ca Administrator
cquilliam-AT-gmail-dot-com

Want to help out Linuxhelp.net? Check out our Linuxhelp Wiki and see if there are some articles you would like to submit!!

--
Ubuntu 8.04 64-bit - Work Laptop (HP-Compaq NC6400 Core2)
Kubuntu 8.04 64-bit - Desktop (HP m8120n QuadCore)
Ubuntu 6.04 - Server (I'm not upgrading this baby until support runs out in 2012) (Some old POS dell)
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 18th October 2017 - 07:08 PM