How to Switch off a Unix machine abruptly

Hi Folks,

My UNIX machine is placed geographically in another location. I have a remote access towards it. I want to abruptly switch off my unix machine through remote connection. Is it possible through any UNIX commands? I practically want to power off a PC , something like unplugging a power cable of a machine which doesnt has a UPS connected to it. Is it possible via any software or statements?

Thanks in advance

Hi gjasper,

You can try;

shutdown -g0 -y -i5

If the PSU can be turned of from the system that should do it.

But remember if it's a PC based system you may have to have someone go and push the button.

If the machine has a Service Controller or a HACMP or ILOM or ALOM, there will be a specific sequence to power it off - accessed through one of these devices.

Regards

Dave

Which OS are you using?

If you want to shutdown the server in a less graceful way than with the shutdown command, you probably want to use the halt or poweroff command.

@Scott , It is Cent OS.

Hi gull04,

The below command did work. It just said the system ins going down in run mode 5. But within 5 minutes the machine was up.It didn't crash out.

shutdown -g0 -y -i5

This can be a known issue with CentOS. Needs a tweak.

See this link:

[CentOS] SOLVED - Shutdown/poweroff does not power off machine

One of the side results of some in-depth HACMP-tests we (some colleagues of mine and me) carried out 15 years ago was a collection of more or less ingenious ways to stop a system as fast as possible. Since then i have tested now and then these methods - more out of curiosity than for any practical purpose. These are the methods we found, listed in order from slow and safe to fast and dangerous:

  1. shutdown -h now

  2. shutdown -fh now
    Some systems use "-F" instead of "-f". Is supposed to skip some safety measures and therefore to be faster.

  3. sync ; sync ; halt
    will be even faster but might (only in extreme cases) damage the system because it stops without anything being closed in order. Still, most systems will survive this and boot more or less properly after being killed that way.

  4. halt -q
    Even faster, but don't try this without a journaling file system (don't try this at all without the need to do so). Old SunOS versions, for instance, had a fair chance of not coming up properly again after such a nosedive. Even with a journaling FS there is some risk, which is why it should only be used as either a very extreme measure or for testing purposes on expendable (test) systems. The same goes for the "winner":

  5. cat /etc/hosts > /dev/kmem
    Any other file will do too - i use this just out of habit. On POWER and PC hardware (and probably on most other hardware too) this was consistently faster than even "halt -q", it takes only about a dozen bytes to be written over the kernel image to crash the system. In AIX this is not possible any more, because even root cannot write to /dev/kmem in newer versions.

I hope this helps.

bakunin

This is a foolish action which is quite likely to damage your data and can result in a system which never works again.

Btw. CentOS is Linux variant. It is not unix.

However if this is a proper server with a management card it should be possible to control the power switch with remote management software (however stupid this action may be). If it is just a PC, not a hope short of using Internet-controlled power switches (which are available).

1 Like

Hi,

If you are brave you could try the "uadmin" system call - should be pretty quick although not sure if the call exists in AIX.

uadmin 1 0	Don't sync drop system to {ok} prompt instantly.
uadmin 1 6	Don't sync and power off the system instantly.

Just remember if it's not commited to disk it's gone and if you are in a production environment, your probably gone too!

Regards

Dave

If you can put a remote console card in the system.

For Dell this would be iDRAC
HP would be iLO

You can do cold power off, come back later when you feel like it and power on.

If your HW supports it, wakeonlan could be another option.

That's because runlevel 5 on Linux is multiuser-mode with console GUI, while on Solaris it means shutdown plus poweroff.

You could try poweroff (or halt -p). Equivalent of the BSD shutdown -p. Should power any machine that understands the system call to power down.

This is CentOS. Let's stick to commands which definitely work on CentOS.