Is there a way I can shutdown a Linux box (CentOS) from a batch file on a Windows machine (win 2012 Server)?

closed as unclear what you're asking by Journeyman Geek Oct 2 '14 at 1:50

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • -1 first look how do you shutdown a linux machine locally(SHUTDOWN COMMAND) then look at how to issue commands remotely(SSH). so ssh to it and issue a shutdown command as root. – barlop Sep 30 '14 at 11:29
  • Yep, I realize that I can use an SSH client like puTTY and issue a shutdown command from there but was looking for something that can be called from a batch file directly to automate the shutdown process in one click. – NickC Sep 30 '14 at 12:02
  • superuser.com/questions/736665/… Please check out the answers here and then edit your question with any addition information you may need to complete the solution. Yours is a question is pointing at useful information, it just needs a little work on your part to become a really good question. – music2myear Oct 8 '14 at 14:34

The final solution I went with was using PLink.exe which is installed in the puTTY package, then create a batch file:


"C:\Program files (x86)\puTTY\plink.exe" -ssh -root@Server1 -pw <password> shutdown -h now

There are more elaborate solutions, but a cheap and cheerful one is to use a flag file in a shared directory and a task which checks its existence, eg:-

if [ -r {shared-dir}/ShutDown ]; then rm {shared-dir}/ShutDown; shutdown -h now; fi

You can run this either in a loop with a sleep 60 (say) command, or as a single command in a script run repeatedly from cron.

Your windows server simply creates {shared-dir}/ShutDown whenever it wants a shut-down.

I hope it goes without saying that {shared-dir} must be writeable from the Linux system, to allow the deletion which both prevents a reboot loop and enables the Windows server to know when the shut-down request has been received and acted on.

Not the answer you're looking for? Browse other questions tagged or ask your own question.