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. |
Can you post the contents of the 2nd batch file (bring server up)? I'm more of a RHEL guy, but I do manage some windows servers and work in Powershell - I might be able to help!
Thanks for the server by the way, have been enjoying myself! -Kapow |
The batch file is the stock one that comes with Akka's installer. I didn't create it.
Code:
@echo off |
And glad you're enjoying the server. It's been a challenge.
|
timeout /t [#seconds]
Might be what you are looking for, I use it in my startups. |
I've never set up an emu server, maybe the server shutdown isn't completed by the time that you start it up again? Some background process? Unless the kill_all_on_start arg in the perl script wipes everything that could be remnant?
|
I figured it out with the help of timeout /t [5 seconds]
AND the most important thing after taking the "exit" off the end of my batch file, I could see why it was not starting the server back up. For perl to find world.exe, etc... the batch file has to be ran from the EQEmuServer folder because in the perl file it doesn't pass a specific directory argument. It was running from desktop before. So for other people's information, here's what my end result looks like in a batch file: Code:
taskkill /IM perl.exe /F |
You're welcome.
Always glad to help. |
One more thing... I got up this morning and the server was down. I checked the task manager and realized I didn't check a box that says "Start in" and put in each task C:\EQEmuServer
Super important or the task manager will run everything from \system32 I think. We'll see how it goes at the next restart at noon. |
It's working! The only thing is, the dos prompt windows don't pop up, and everything runs in the background.
|
All times are GMT -4. The time now is 01:43 PM. |
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.