Solved

restart servers in list

Posted on 2014-12-19
8
144 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 38

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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 

Author Comment

by:naveen mullaguri
ID: 40510529
@Gerwin


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

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 25

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 38

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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

Suggested Solutions

This is an article about Leadership and accepting and adapting to new challenges. It focuses mostly on upgrading to Windows 10.
Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
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…

856 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