Auto Restart

Auto Restart

70.3k Downloads

[Question] How to use Task Scheduler to use the restart scripts while keeping console windows open?

Nycto97 opened this issue · 4 comments

commented

Description

So for hours upon hours I've tried using Task Scheduler to run restart_start.cmd while also keeping the cmd window open + opening the actual server console.

Manually running restart_start.cmd DOES open a cmd window and it opens the server console when the server is launched, allowing me to input commands in the cmd console to control the server.

I'm able to wake pc from sleep and successfully run the script with Task Scheduler, but the problem is that it always launches the server without any window opening. The only place I can see the server is in Task Manager. Ending the task here will automatically restart the process so I need to go in-game every time to shutdown the server.

I've tried many things, including using /k in some places, but nothing works.

Do you have any idea how I can achieve this? Can I replace the cmd scripts with bat scripts to be able to use the /k argument?

Any help is much appreciated!

restart_start.cmd:

cd "G:\Program Files\Minecraft\versions\1.19.2-forge-43.3.7\Server Nycto\"
start .\restart_loop.cmd

restart_loop.cmd:

echo OFF
:start
    title Minecraft Server
    "C:\Program Files\Eclipse Adoptium\jdk-17.0.10.7-hotspot\bin\java.exe" @user_jvm_args.txt @libraries/net/minecraftforge/forge/1.19.2-43.3.7/win_args.txt %*
    SET /p should_restart=<./auto_restart/restart
    if %should_restart% EQU 0 goto stop
    echo If you want to stop the server completely, press CTRL-C, \before the countdown is at 1!
    echo Rebooting in:
    timeout /T 3 /nobreak
    echo "==================================================="
    echo "==================================================="
    echo "==================================================="
    echo "===============  RESTARTING SERVER  ==============="
    echo "==================================================="
    echo "==================================================="
    echo "==================================================="
    goto start
:stop
config:

#Options for restarting:
[restart]
	#Is the server started by an external restart script?
	use_external_restart_script = true
	#Command that is executed on Server stopped to restart the server. Only called if "[restart, use_external_restart_script]" is false.
	restart_command = ""

#Option for auto restarting:
[auto_restart]
	#Should the Server do automatic restarts?
	enabled = true
	#Times in 24-hour format on which the server will automatically restart
	times = ["08:00"]
	#Should the server be automatically restarted when it crashes.
	on_crash = true
	#Times before an auto restart of the server, a restart warning should be shown.
	#Examples:
	# - 5s - For a message 5 seconds before a restart
	# - 7m - For a message 7 minutes before a restart
	# - 2h - For a message 2 hours before a restart
	warning_times = ["30s", "20s", "15s", "10s", "5s", "4s", "3s", "2s", "1s"]

#Options for restart, if the server is empty:
[on_empty_restart]
	#Should the server restart, if no players are online?
	enabled = false
	#Delay after the server should restart, if it is empty.
	#Examples:
	# - 5s - For a delay 5 seconds
	# - 7m - For a delay 7 minutes
	# - 2h - For a delay 2 hours
	delay = "10m"

#Options for restart, if the tps of server or its dimensions are low:
[low_tps_restart]
	#Should the server restart, if it is below a tps level for a specified time?
	enabled = false
	#TPS level below which the server is restarted, if it lasts for a specified time.
	#Range: 0.0 ~ 20.0
	minium_tps_level = 0.0
	#Delay, that the server must be below the defined TPS level, in order for it to be restarted.
	#Examples:
	# - 5s - For a delay 5 seconds
	# - 7m - For a delay 7 minutes
	# - 2h - For a delay 2 hours
	delay = "1m"


Task Scheduler:

image

image

image

image

References (optional)

No response

Additional info (optional)

No response

commented

This issue/pull request has been automatically closed because it has not had activity in a long time.

commented
commented

Thank you so much! I will try it when I have the time for it and let you know if it worked :)

commented

This issue/pull request has been automatically marked as inactive because it has not had recent activity. It will be closed if no further activity occurs.