1

we have many ubuntu computers in our lan, i have created a script to run it remotely from my windows computer to a list of linux computers by using putty and the m parameter

the problem is that in the end of the script there is a reboot, so the windows of putty session wont disappear because linux computer reboots before the script is finished running my windows script over 100 linux computers will result of 100 open putty windows !

i tried "shutdown -r +1" instead of "reboot" but the result is the same

i am seeking a way to reboot linux computer, but this command must be executed and terminated without waiting for the countdown, the shutdown command persist after executing it, so the script won't terminate !

thanks

2
  • So essentially, you're looking for a way to force a reboot and in the process of doing that, kill all processes that are currently running? Is that it? You might be looking for reboot -f now or shutdown -r -f now
    – Vinayak
    Dec 6, 2014 at 14:23
  • 2
    shutdown -r now would be my option
    – LPChip
    Dec 6, 2014 at 14:43

3 Answers 3

1

Quick and dirty: fork the shutdown command by appending an ampersand & after the command, then exit the terminal session in the script. See e.g. 1, 2, or any tutorial on shell script syntax.

Less hacky: look for solutions that allow you to administer multiple hosts simultaneously, other than starting single PuTTY process to connect to each of them. See e.g. Linux - Running The Same Command on Many Machines at Once.

1
  • thanks for the ampersand clue, i think i will opt for it
    – hiboujid
    Dec 6, 2014 at 16:08
0

ansible is another way to do it and a lot of other things.

https://support.ansible.com/hc/en-us/articles/201958037-Reboot-a-server-and-wait-for-it-to-come-back

0

Have you tried using plink and pscp instead of PuTTy? Here's an older StackOverflow thread that suggests using those for remote command execution:

https://stackoverflow.com/questions/11001508/to-run-shell-script-with-parameters-on-windows-command-line-via-putty-exe

Are you familiar with Cygwin? It provides you a reasonable emulation of a true Linux environment with most of the standard Linux tools. Homepage: https://www.cygwin.com/.

Maybe you could run a Linux distro on a virtual machine on your PC? That way you'd have access to all the tools mentioned in the thread Daniel linked. And since this looks like CLI stuff, you don't need to reserve huge amounts of RAM or HDD space for it.

EDIT:

Yet another possible solution to have a full Linux arsenal at your disposal: get a RasPi. Once it's installed, you can just leave it running somewhere in the network and ssh into that to do this kind of administrative tasks. Homepage: http://www.raspberrypi.org/

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .