Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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?
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.