LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Mandriva
User Name
Password
Mandriva This Forum is for the discussion of Mandriva (Mandrake) Linux.

Notices


Reply
  Search this Thread
Old 01-26-2005, 08:43 PM   #1
Hexane
LQ Newbie
 
Registered: Dec 2004
Posts: 27

Rep: Reputation: 15
Shutdown script


Is there some script some where that gets called before the computer shuts down. I want to add something simple to save my total download/upload amounts by grabing them from /proc/net/dev before the computer turns off every time.
 
Old 01-26-2005, 08:56 PM   #2
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 48
You can install a script in your runlevel 0, and run level 6, to capture them.
 
Old 01-26-2005, 09:03 PM   #3
Hexane
LQ Newbie
 
Registered: Dec 2004
Posts: 27

Original Poster
Rep: Reputation: 15
Where do I do that? some where in like /etc/init*?
 
Old 01-26-2005, 09:05 PM   #4
Hexane
LQ Newbie
 
Registered: Dec 2004
Posts: 27

Original Poster
Rep: Reputation: 15
wait... /etc/rc0.d and /etc/rc6.d do I just add it in there?
 
Old 01-26-2005, 09:22 PM   #5
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 48
There's another directory /etc/init.d you put the script in there. Something like

Code:
#!/bin/sh
case "$1" in
    start )
        #Put your code here
    ;;
    stop|restart|status )
        echo "This script does not do anything for $1"
    ;;
    * )
        echo "usage:$0 {start|stop|restart|status}"
        exit 1
    ;;
esac
Then create two symlinks one in /etc/rc0.d and one in /etc/rc6.d with

cd /etc/rc0.d
ln -s ../init.d/scriptname S10scriptname
cd ../rc6.d
ln -s ../init.d/scriptname S10scriptname

The numbers are low in case anything that is shutdown by a script later thats required is still there.

Edit: also don't forget to make the script executable
chmod +x scriptname

Last edited by leonscape; 01-26-2005 at 09:26 PM.
 
Old 01-27-2005, 01:41 AM   #6
bunnadik
Member
 
Registered: Jan 2005
Location: Övik, Sweden
Distribution: MDK 10.1
Posts: 450

Rep: Reputation: 30
Quote:
The numbers are low in case anything that is shutdown by a script later thats required is still there
Except the two scripts that turn everything off are run as S00... and S01... i.e. before that script.
So you probably want to rename them to something higher than 10 or it won't work.
Code:
mv /etc/rc6.d/S00killall  /etc/rc6.d/S11killall && /etc/rc6.d/S01reboot  /etc/rc6.d/S12reboot
mv /etc/rc0.d/S00killall  /etc/rc0.d/S11killall && /etc/rc0.d/S01halt  /etc/rc0.d/S12halt
- Peder
 
Old 01-27-2005, 07:57 PM   #7
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 48
Thats weird mine are set too 90, so what happens to all the stuff that needs shutting down on Madrake? They just get killed?
 
Old 01-28-2005, 01:36 AM   #8
bunnadik
Member
 
Registered: Jan 2005
Location: Övik, Sweden
Distribution: MDK 10.1
Posts: 450

Rep: Reputation: 30
That's what the "K" entries are for (IIRC). When changing runlevel the system first runs the K(ill) entries in the new runlevel
(I've got 21 of them in rc0.d). Then it "starts" the S ones.

Thinking of that Hexane perhaps have to put his script in K30 or something depending on if K90network clears some entries.

- Peder
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
startup and shutdown script android6011 Slackware 3 11-03-2005 04:04 PM
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 Zolan Linux - Newbie 2 10-16-2004 09:02 PM
Editing Shutdown Script coolamit78 Red Hat 2 09-14-2003 06:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Mandriva

All times are GMT -5. The time now is 06:29 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