ScheduledShutdown
ScheduledShutdown
Purpose
There are a lot of plugins out there that I have seen that try to keep the memory fresh and the lag low. Sadly most use an interval type deal where it can shutdown every 8 hours or so. If you want to have the machine running the server to restart as well, then the added time would throw the interval way off and would end up restarting at peak times.
Description
This plugin solves the problems of anyone who wants a simple lightweight daily shutdown/restart at a specific time every day forever.
The config is super simple, on the first line put 0-23 for the hour to stop, and on the second line put 0-59 for the minute you want it to stop. Done!
Blank config file gets made if it does not exist.
Installation
- Place JAR in plugins folder
- Run server or reload (prefer reload as you have to stop again)
- It will generate folder and config file, open config
- put hour on first line
- minute on second
- save
- now restart the server
Config
If you want it to stop at midnight you would put
0 0 or 00 00
Those would be read the same, if you want it to stop at 7:37PM you would put
19
37
Notes: Do not put anything else before the two lines of time, let alone the entire file. The config will be updated in the next release of the plugin. All times are local to the machine running the server.
To Restart
This is accomplished in the startup scripts using infinite loops:
For Windows
Click for ADVANCED WINDOWS SCRIPTS
Put ":start" on the line before what you want repeated, then "goto start" on the line after what you want repeated to make an infinite loop. Example craftbukkit.bat:
@ECHO OFF SET BINDIR=%~dp0 CD /D "%BINDIR%" :start "%ProgramFiles%\Java\jre6\bin\java.exe" -Xmx1024M -Xms1024M -jar craftbukkit.jar goto start
For *nix OSes
Put "while true" <new line> "do" on the lines before what you want repeated, and "done" on the line after to make an infinite loop. Example craftbukkit.sh:
#!/bin/sh BINDIR=$(dirname "$(readlink -fn "$0")") cd "\$BINDIR" while true do java -Xmx1024M -Xms1024M -jar craftbukkit.jar echo "If you want to completely stop the server process now, press Ctrl+C before the time is up!" echo "Rebooting in:" for i in 5 4 3 2 1 do echo "$i..." sleep 1 done echo "Rebooting now!" done
Ending Loop
On Windows, to exit this infinite loop (i.e., take the server down for good), simply close the command window. On Linux, stop the server then press "Ctrl+C" to cancel the process.
Need Help? Video Tutorial
Tutorial provided with thanks by randycougar
Notes
This plugin is super lightweight and simple, taking up next to no memory or processing power
It broadcasts a notice about the approaching shutdown one minute prior.
Scripting from SimpleRestart's Description
Plans
- Restart every "x" days - or - restart on mon,wed,fri or every tuesday or whatever you want
- Set time in-game
- A reload command
Provide the source code of the plugin =)
This plugin is great, thanks for your effort. I have only one issue.
My server restarts multiple times during the minute specified. (3 to be exact.)
Is there a simple fix for this? Thanks again.
EDIT:
FIX: I added this line to the Craftbukkit batch...
PING 1.1.1.1 -n 1 -w 60000 >NUL
before goto start and after the .jar execution, on it's own line.
The batch file now waits 60 seconds after the timed shutdown, and before restarting.
It tries to ping the IP 1.1.1.1 with a 60 second timeout.
Thanks!
great plugin
@LordValgor Set up the config... Enter the hour on the first line minute on the second
Had an awesome idea to have an automatic server! Mac: http://www.youtube.com/watch?v=6h2dFqn27ys
Windows out soon
Getting an error message when starting my server
09:29:32 [INFO] [ScheduledShutdown] Enabling ScheduledShutdown v1.0 09:29:32 [SEVERE] Error occurred while enabling ScheduledShutdown v1.0 (Is it up to date?) java.lang.NumberFormatException: null at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at org.hpiz.scheduledshutdown.ScheduledShutdown.reload(ScheduledShutdown .java:67) at org.hpiz.scheduledshutdown.ScheduledShutdown.onEnable(ScheduledShutdo wn.java:35) at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:215) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader .java:337) at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage r.java:381) at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:256) at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:238 ) at net.minecraft.server.MinecraftServer.t(MinecraftServer.java:381) at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:368) at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:197) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:432) at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
Any ideas?
@hpiz
Awesome! This definately helped me out so much! The only other one is not updated! I can't have my server run 24/7 but I wanted to close at 12:00PM and it got tiring! I can now go to bed whenever i want, but still be sure the server will shutdown, and not fry my computer by running nonstop. Love you man!
@kyledag500
Absolutely, I threw this first version together as a necessity for my own server so it has the bare minimum of features. My semester just ended so I am gonna start on an update, which will include what I have under the plans section along with this suggestion.
For your issue I will make it fully customization with as many or few announcements so the config option would look like
warnings=0:05,0:10,0:30,60:00,120:00
basically whatever you want
Can you Please make it broadcast at say like 5 min, 1 min, and 10 sec? Or maybe make it more customizable? Some people miss the 1 message that it gives.
@joshwenke
I believe it is the same as Linux if I'm not mistaken, you should be able to use the same looping that the .sh script does, maybe just have to change a few keywords. I don't have access to a Mac so I can not help with the restart scripting, but the shutdown will certainly occur at the time you specify.
Mac?