LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 08-24-2004, 01:25 PM   #1
zer0halo
LQ Newbie
 
Registered: Aug 2004
Distribution: FC2, MDK10
Posts: 2

Rep: Reputation: 0
Question Where do you place shutdown scripts?


Where do you put scripts that will be executed at shutdown, and how do you reference those scripts? (For example, I want to create a script that clears out certain temp folders, wipes my free space, etc., whenever I shut down the computer.)

I guess I could just create a script with the 'shutdown' command and then invoke that script to shut down the computer rather than FC2's own "logout" option. But my question is - can you put scripts somewhere so that they execute automatically whenever the computer is shut down normally?

Similar question, can you put a script somewhere that executes automatically when you log out (without shutting down)?

Thank you!

(Running Fedora Core 2.)
 
Old 08-24-2004, 01:43 PM   #2
King4lex
Member
 
Registered: Aug 2004
Distribution: Fedora Core 4
Posts: 90

Rep: Reputation: 15
I think this is what u are looking for:

Quote:
There are 7 folders (which are typically found in the /etc directory, if
they are not there search the /etc directory because they may be i another
subdirectory of /etc):
- rc0.d
- rc1.d
- rc2.d
- rc3.d
- rc4.d
- rc5.d
- rc6.d

These correspond to the different run levels that Linux has.
- Runlevel 0 is when you turn your computer off.
- Runlevel 1 is single user mode
- Runlevel 2 is multi user mode w/o NFS
- Runlevel 3 is multi user mode w/NFS
- Runlevel 4 is reserved for different vendors to define
- Runlevel 5 is GUI mode.
- Runlevel 6 is when you reboot your computer.

If you look into the rc0.d you'll see a bunch of scripts (or symlinks to
scripts). They either start with a "K" or an "S". When your Linux system
starts into a Runlevel it looks inside of it's corresponding rcX.d folder.
Scripts that start with a "K" are stopped or killed. Scripts that start with
an "S" are started. You'll also notice that after the "S" or the "K" is a
number. When scripts are started it will start "S1script" before
"S99script". The reverse goes for "K1script" and "K99script" (this is killed
first)

If you would like start a script at boot, you need to make a script. For VNC
you can just as easily use a bash script. Copy the following into a file
named "boot.vnc" and place this in the /etc/init.d folder.
 
Old 08-24-2004, 04:30 PM   #3
zer0halo
LQ Newbie
 
Registered: Aug 2004
Distribution: FC2, MDK10
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks so much. Exactly what I needed.

I presume that scripts placed in rc6.d execute on logoff even if the computer isn't rebooted?
 
Old 08-24-2004, 04:43 PM   #4
King4lex
Member
 
Registered: Aug 2004
Distribution: Fedora Core 4
Posts: 90

Rep: Reputation: 15
Quote:
Originally posted by zer0halo
Thanks so much. Exactly what I needed.

I presume that scripts placed in rc6.d execute on logoff even if the computer isn't rebooted?
I'm fairly new to linux myself so I don't know. It depends if linux goes into runlevel 6 when you logout. I don't think it does (can someone else confirm this?).

I just remembered another way to execute scripts. Add a .logout file to your home directory. I believe you must make it executable for it to work (use chmod +x .logout). Scripts inside the .logout file will get executed whenever you logout. You might want to put scripts there instead of rc6.d. (sorry I didn't remember it before). Hope this 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
shutdown scripts? mushmaster Linux - Software 5 02-15-2005 07:23 PM
Emergency Shutdown scripts? samroberts Linux - Enterprise 3 10-29-2004 05:48 AM
Want to run a few scripts before KDE shutdown, where can I add them. Brian1 Linux - Software 6 06-16-2004 07:36 PM
Suitable place to run bash scripts Skyline Programming 7 01-21-2004 08:37 PM
Good place to find scripts? twistedpair Linux - General 3 01-15-2004 02:15 PM


All times are GMT -5. The time now is 10:55 PM.

Main Menu
Advertisement
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