Solved

restart servers in list

Posted on 2014-12-19
8
143 Views
Last Modified: 2014-12-20
i have a list of servers in "servers_list.txt" file. how can i trigger restart all the servers in list from a server in network.
0
Comment
Question by:naveen mullaguri
8 Comments
 
LVL 4

Expert Comment

by:Kent Fichtner
ID: 40509081
I am sure you can do this with a program but the best idea I have is the shutdown command in windows.  you would just take the text document and make it a batch file adding the following:

shutdown /r /t 0 /m \\<computer1>
shutdown /r /t 0 /m \\<computer2>
shutdown /r /t 0 /m \\<computer3>

that should work.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40509100
On a administrative command prompt:

for /f %f in (servers_list.txt) do @echo shutdown /r /t 0 /m "%f"

(test mode - remove echo in above line for real)

In a batch file:

for /f %%f in (servers_list.txt) do @echo shutdown /r /t 0 /m "%%f"

(put in same folder as .txt file and call from administrative command prompt)
0
 
LVL 17

Expert Comment

by:Emmanuel Adebayo
ID: 40509107
You can use psshutdown You can download from MS technet link below

http://technet.microsoft.com/en-gb/sysinternals/bb897541.aspx

Command usage

Go to the directory where you have the executable and run the following

psshutdown.exe -r -f -c -t 60  @servers_list.txt

Not that the servers_list.txt must be in the same directory as the executable is other wise you have to use the full path with @

Hope this helps
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:naveen mullaguri
ID: 40510529
@Gerwin


i got the restart usage error as attached. please advise.
restart-error.gif
0
 
LVL 37

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 500 total points
ID: 40510544
Look at the 'usage' message that you get from the shutdown command. You are not putting the machine name (from your servers.txt file) after the /m parameter.

Besides that: for testing do as I suggested leaving the echo command in there. Are you running this from a batch file? I cannot see that from the screenshot you posted, if so then you have to use %%f instead of %f (see above as well).

Your shutdown line would have to be like this if in a batch file:
for /f %%f in (d:\cognos_server_restart\servers_list.txt) do echo shutdown /r /m "%%f" /t 120 /d p:2:17 /c "Your comment"

Open in new window


If you leave the echo in, you will see the command that would be sent, including the server name(s) that you are about to restart.

Your server.txt file should look like this:

Server1
Server2
Server3

etc.

What do your server names look like?
0
 
LVL 24

Expert Comment

by:Lionel MM
ID: 40510712
for /f %%f in (d:\cognos_server_restart\servers_list.txt) do echo shutdown /r /m "%%f" /t 120 /d p:2:17 /c "Your comment"

I would only add to force a shutdown                            
for /f %%f in (d:\cognos_server_restart\servers_list.txt) do echo shutdown /r / f /m "%%f" /t 120 /d p:2:17 /c "Your comment"

also you did run the command froma dos prompt--the above will work if in a batch file but if you run it from a dos prompt, the command line you must remove one of the %'s like this--from %% to just %
for /f %f in (d:\cognos_server_restart\servers_list.txt) do echo shutdown /r / f /m "%f" /t 120 /d p:2:17 /c "Your comment"
0
 
LVL 37

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40510716
@lionelmm - I already mentioned twice about single % our double %% - you are repeating what has been said already...
0
 

Author Closing Comment

by:naveen mullaguri
ID: 40511343
thank you so much
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to install windows?? 2 43
Windows shadowcopy - space allocated - exclusive? 4 27
facebook change 4 39
Disk Cleanup and Temporary Files 15 41
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question