LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Automatic shutdown when power button pressed.. (http://www.linuxquestions.org/questions/linux-general-1/automatic-shutdown-when-power-button-pressed-90148/)

mr_smidge 09-07-2003 08:53 AM

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.
:newbie:

darthtux 09-07-2003 01:53 PM

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.

mr_smidge 09-07-2003 02:01 PM

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?

J.W. 09-07-2003 02:21 PM

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.

Caeda 09-07-2003 02:44 PM

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!

darthtux 09-07-2003 02:48 PM

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.

contrasutra 09-07-2003 06:02 PM

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

mr_smidge 09-07-2003 06:48 PM

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.

michaelk 09-07-2003 07:45 PM

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

J.W. 09-08-2003 02:16 AM

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.


All times are GMT -5. The time now is 06:17 AM.