LinuxQuestions.org
Visit Jeremy's Blog.
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 09-07-2003, 08:53 AM   #1
mr_smidge
LQ Newbie
 
Registered: Dec 2002
Distribution: Gentoo
Posts: 22

Rep: Reputation: 15
Automatic shutdown when power button pressed..


I am currently running a linux fileserver, and I would like to make it possible so that once the machine is running, then by pressing the power button it will automatically shutdown and switch off. Currently, pressing the power button doesn't do anything.

How would I set it up (using APM or whatever) so that the machine will automatically shutdown?

Thanks in advance.
 
Old 09-07-2003, 01:53 PM   #2
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480° N, 95.3690° W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 47
It's never a good idea to shutdown just using the power button. Linux has a sequence it has to go through to unmount devices and filesystems safely. If you just turn the button off, it could corrupt your filesystem.
 
Old 09-07-2003, 02:01 PM   #3
mr_smidge
LQ Newbie
 
Registered: Dec 2002
Distribution: Gentoo
Posts: 22

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by darthtux
It's never a good idea to shutdown just using the power button. Linux has a sequence it has to go through to unmount devices and filesystems safely. If you just turn the button off, it could corrupt your filesystem.
I realise that.. what I am trying to achieve is for linux to go through the whole normal shutdown procedure when the button is pressed, not a hard power-off. Is this possible?
 
Old 09-07-2003, 02:21 PM   #4
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 87
Comments:
1.As darthtux already said, it would be a poor idea to just power off the machine. It would be equivalent to yanking the plug out of the socket, and the risks of damaging your system would be high.
2. AFAIK, No, there is no way to "attach" a shutdown procedure to the power button.
3. Regarding your comment that "pressing the power button doesn't do anything" -- some machines, like my Dell at work, require that you hold the power button down for several seconds before the power cuts off. The idea presumably is to minimize the chances of an accidental shutdown. -- J.W.
 
Old 09-07-2003, 02:44 PM   #5
Caeda
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Suse 6.0+, Mandrake 5.0-10.0, Redhat 6.0-9.0, Gentoo 1.2+, Gnoppix, Knoppix, Sabayon, Ubuntu 5.04+
Posts: 1,811

Rep: Reputation: 45
Here are a few things to try.

http://www.cs.helsinki.fi/linux/linu...1-31/0968.html
http://www.netfort.gr.jp/~matsu/i82371/README
http://lists.debian.org/debian-user/.../msg04077.html

And some advice for the others,
if you dont know how to fix or do what someone asks, don't answer!
 
Old 09-07-2003, 02:48 PM   #6
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480° N, 95.3690° W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 47
Quote:
Originally posted by Caeda
And some advice for the others,
if you dont know how to fix or do what someone asks, don't answer!
I gave good advice. How was my advice bad? He replied back and clarified the situation. If someone is not a moderator please don't suggest to me when not to answer. I try to help everyone I can.

BTW, click on the search button under my name. A lot of people have thanked me for helping them.

Last edited by darthtux; 09-07-2003 at 03:14 PM.
 
Old 09-07-2003, 06:02 PM   #7
contrasutra
LQ Guru
 
Registered: Mar 2003
Location: New Jersey
Distribution: Arch Linux
Posts: 1,445

Rep: Reputation: 47
First, try shutting down the computer with the command "poweroff".

Does your computer shutdown and poweroff?

If it does, you may be able to do this.


To find out if your power button can do this, you need to know if you have a "software power button".

If you do, its just a matter of mapping that "key" to the "poweroff" command.


Check out this thread for all the info, it helped me:

http://bbs.archlinux.org/viewtopic.php?t=937
 
Old 09-07-2003, 06:48 PM   #8
mr_smidge
LQ Newbie
 
Registered: Dec 2002
Distribution: Gentoo
Posts: 22

Original Poster
Rep: Reputation: 15
I used to have a keyboard with a "Power Off" button, that when pressed, under Windows, would go through proper shutdown and switch off the machine. This is effectively what I'm trying to get at, but using the power switch on the case rather than a key on the keyboard.

J.W.: In regard to your 3rd point, I know that holding the power button down does a hard power-off, but it is the one-touch press that does something else, that currently isn't set to do anything - hence my comment about it not doing anything.. Sorry if I was unclear.

Here's a short explanation of how the server currently acts: It is used by my entire family as a file/print server, and I'm not always here, so I'm trying to make it as easy as possible for the non-techie members of the family to use. To switch on, just press power.. easy. To switch off, I've made a user called "shutdown", and if you log on as that user then the machine automatically shuts down and switches off. That's a step in the right direction, but if possible I'd like to make it even easier. This is why I'm trying to map a software command to the power button being pressed, as I've described.

Caeda & contrasutra: I will read those links and try what I can, and I'll report my progress here for future reference.

Thanks people.

Last edited by mr_smidge; 09-07-2003 at 06:49 PM.
 
Old 09-07-2003, 07:45 PM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
In the mean time you can set the ctrl-alt-del sequence to shutdown the system. Not familar with gentoo but usually its configured to reboot.

The configuration setting is located in /etc/inittab file
 
Old 09-08-2003, 02:16 AM   #10
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 87
Mr Smidge - I understand your point. The original intent of my post was really only to emphaize the dangers of doing a hard power down without allowing the system to do an orderly shutdown first. About a year ago we had a blackout in my neighborhood during a storm, and long story short, it killed my system, and I needed to do a reinstall as a result. If anything I can say can help someone else avoid the same predicament, I'll put in my 2 cents.

Caeda - I suppose that your, um, "scolding" might also be directed at my post. Not to be defensive, but considering that points #1 and #3 in my post are factually correct, and that I prefaced point #2 with "AFAIK", I fail to see how my post could possibly be considered misleading or incorrect. Since you seem to be so keen on doling out advice to others, I'll assume that you're equally receptive to being given advice yourself, and with that in mind, you might consider this (and again I'll second darthtux): Unless you're a moderator, please refrain from broadcasting your opinion on who should or should not submit a well-intentioned reply to a question. In my experience with this board, we're all just trying to lend a helping hand in whatever way we can. Regards. -- J.W.
 
  


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
Power Button for Shutdown gokul Linux - Hardware 4 01-24-2004 12:40 PM
ACPI: shutdown computer by pushing power button... elluva Mandriva 10 12-15-2003 03:57 AM
RH 9 orderly shutdown by power button? geezjan Red Hat 1 09-19-2003 10:01 AM
Shutdown with power button hriosm Linux - Hardware 4 06-06-2003 02:43 PM
Shutdown routine with power button bfought Linux - Newbie 2 09-09-2002 06:23 PM

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

All times are GMT -5. The time now is 08:50 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
Open Source Consulting | Domain Registration