0

I've written a stored procedure that I use as a scheduled job in MSSQL to reboot a list of servers, I also log all response messages as errors\warnings in case reboot doesn't go well. All was fine as long as we used to use OpenSUSE, now we've installed various new servers and are tending to use Ubuntu.

The command that is run from MSSQL is (after doing it manually the first time to cache the RSA key):

putty.exe -ssh user@server -pw [password] -m D:\SQL\APPS\reboot.txt

It works (as in the server actually reboots) but it always answers with a "Server unexpexclty closed network connection" and this is very annoying as I keep on logging it as an error and then sending out alert emails to me and other net admins.

Anyway I can avoid this response? Different way to reboot ubuntu from MSSQL maybe?

Obviously I realize I could write a big IF in my stored procedure and ignore messages that contain "Server unexpexclty closed network connection" but I kinda wanted to avoid this route.

Thanks for any suggestions, James

James
  • 203
  • 1
  • 8

1 Answers1

1

You can just end ssh connection correctly. For example instead of using just reboot you can use reboot ; exit

BTW why are you restarting servers from MSSQL database itself? If you just want to do restart in some point of time, use cron locally.

Ondra Sniper Flidr
  • 2,653
  • 12
  • 18
  • This didn't work, I'm still getting the message. I'm running it from MSSQL because I have one single place where I list all my servers and reboot them without having to install and create a cron job in each server. Plus I have various kinds of servers and I manage the different reboots base on server type in one only stored procedure, so all I have to do is have a job that runs Reboot [servername] – James Jul 28 '17 at 12:57
  • Still seems like a bad idea to reboot server from mssql. Perhaps look into a real solution like ansible or puppet? – Daniel Widrick Jul 28 '17 at 13:47
  • Could you explain why you think it's a bad idea? Not trying to be funny, I just want to understand, – James Jul 31 '17 at 06:39