Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

restart servers in list

Posted on 2014-12-19
8
Medium Priority
?
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 18

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
Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

 

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

722 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