Making a batch file for a server

joce21

Distinguished
May 30, 2010
2
0
18,510
Hi the community!!

I host a server Minecraft on a computer with Vista and I must restart my server manually for maintenance. I'm not very good in Batch files and I'm looking for something that would stop and restart my server/computer at a specific time automatically.

The batch file would be like:

"At a specified time, (Example: at 3 am)

Stop the server (Write stop in the cmd (The server window already open)),
Restart the computer,
Start the server (Run my startServer.bat)."

To run my server, I run a Batch file (startServer.bat) with this line :
java -Xms512M -Xmx1024M -jar craftbukkit-0.0.1-SNAPSHOT.jar

Waiting for you responses :p
 

Rusting In Peace

Distinguished
Jul 2, 2009
312
0
19,060
You can use the Task Scheduler to run programs of your choice. Programs -> Accessories -> System Tools -> Task Scheduler.

So create two tasks

1) On machine boot run startServer.bat

2) If you don't care that the server wouldn't be shutting down cleanly, you could have a task that restarted that computer at 3am. Doing a restart would obviously shut down the running server.

Stopping the server cleanly will be a little harder because you are running a batch file rather than being in the server console window.
 

joce21

Distinguished
May 30, 2010
2
0
18,510
Is there a way to create a file that will automatically send "s-t-o-p" and "enter" to the OS ?

So I can make a task scheduler to call this file at 2:59 and another one task scheduler that start at 3am and reboot my computer?