Solved

restart servers in list

Posted on 2014-12-19
8
140 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
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 16

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
 

Author Comment

by:naveen mullaguri
ID: 40510529
@Gerwin


i got the restart usage error as attached. please advise.
restart-error.gif
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 37

Accepted Solution

by:
Gerwin Jansen 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:lionelmm
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
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now