LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-03-2006, 02:51 AM   #1
Niceman2005
Member
 
Registered: Nov 2004
Distribution: Fedora Core 2
Posts: 330

Rep: Reputation: 30
any way I can autorun a script before when shutdown


Dear friends,

I have auto mount script at my /etc/rc.local, just wondering if there is a way for me to auto run certain scripts such as unmount a drive upon shutdown? is there a /etc/rc.local for shutdown ?

thanks for taking time helping,

Regards
Niceman
 
Old 03-03-2006, 02:56 AM   #2
Jaqui
Member
 
Registered: Jan 2006
Location: Vancouver BC
Distribution: LFS, SLak, Gentoo, Debian
Posts: 291

Rep: Reputation: 36
on shutdown, if it's an orderly shutdown then all filesystems are automatically unmounted as part of the process.

rc.6 is the reboot runlevel, rc.0 is the shut down and power off runlevel.
 
Old 03-03-2006, 06:12 AM   #3
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
You need to put your script to run in some run level.
Put it at /etc/init.d and create symbolic links to it in /etc/init.d/rc<n>.d/ (the path may vary in your distro).
Check theses directories to see how the linking is done. The ones that start with "S" are executed when the system enters in that level, and the ones that start with "K" are executed when the system leave from that run level.
The number shows the order of execution. Low numbers are executed first.
 
Old 03-03-2006, 08:24 AM   #4
dussel
Member
 
Registered: Dec 2004
Distribution: SuSE 9.X, SuSE 10, SLES 9,RedHat, Feodora Gentoo, Solaris, and more
Posts: 50

Rep: Reputation: 15
I usually puts I all "stop/umount"-script in /etc/init.d than a soft-link to rc6.d because every time you reboot, or make a shutdown will your script be run.

Cheers


Dussel

Last edited by dussel; 03-03-2006 at 08:25 AM.
 
Old 03-03-2006, 05:40 PM   #5
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
My Fedora box has several umount commands in /etc/rc.d/init.d/halt .
I have used that file to eject the cdrom just before shut down and maybe you could get some ideas by looking at the existing lines.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script at the shutdown dominant SUSE / openSUSE 4 10-15-2005 07:43 AM
shutdown script acidjuice Slackware 3 04-09-2005 05:19 PM
Shutdown script Hexane Mandriva 7 01-28-2005 01:36 AM
shutdown script Zolan Linux - Newbie 2 10-16-2004 09:02 PM
Autorun.sh script to mount CD and run .bin file kulkarni08 Linux - General 2 06-24-2003 01:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:01 AM.

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
Open Source Consulting | Domain Registration