View Single Post
  #1  
Old 07-28-2017, 11:30 PM
Fridgecritter
Hill Giant
 
Join Date: Feb 2008
Posts: 188
Default Automatic server restart using task manager

I am using Server 2016 and I need to accomplish a few things automatically every 6 hours:

Shut down the server
Run two queries on the database one at a time (they run quick)
Bring the server back up

So I tried using the windows task scheduler, made two batch files, one for each query I needed to run, and then made 4 scheduled tasks...

6PM take down server (calls t_server_stop.bat)

6:01 Run query1 (calls to a batch file that runs mysql --user=root --password=mypass peq < c:\query1.sql)

6:02 Run query2 (calls to a batch file that runs mysql --user=root --password=mypass peq < c:\query2.sql)

6:03 Bring server back up (calls t_server_start.bat)

But for some reason it brings the server down, runs the two batch files but doesn't bring the server back up. And I set the tasks to be run even if the user isn't logged on, and run with admin privileges)

So, I'm thinking of consolidating it all into one batch file, but I don't know how to do that. Once it logs into the mysql prompt, dos commands like sleep, etc... don't work. Can someone school me and teach me something about creating a batch file to call a combination of dos commands and mysql commands, so I can have task scheduler call one batch file and be done with it? Thanks a ton in advance.
Reply With Quote