Question about cron


#1

Does cron have the ability to see that a server is down and auto-start it?
If {server.activity=STOP} then {server.run} (don’t know if that makes more sense or not… very tired)
(All i have seen is people asking for a specifically timed reboot )


#2

I don’t believe cron is capable of knowing what is running or not. as far as I know, it is a task scheduler only. However, someone much smarter than me in Linux scripting could come up with a program to check if the server(s) are running. Then use cron to run that. It might look something like: if running, end; if not running, execute command.

I saw a post where you can start a server in console, but not sure when or by whom. Hope this helps.


#3

depending on knowhow and how much it is wanted, it is possible to use something like Zabbix to do that. Zabbix are able to test to see if a port is open and possible to connect to (and even measure how long it takes / pingtime). You can tell zabbix to run a restartscript if a test fails or a ping gets to high.

Zabbix is kind of resource hungry, and really needs it’s own machine (Either virtual or not), and an agent to run on your mineos machine. It also take ALOT of configruation, svearing and offering of chickens to make it work like you want. The furthest I bothered to get as a test a few years ago was to make Zabbix test my servers, and mail me if something wasn’t working.


#4

I’ve engineered a function for this exact purpose: verify.

Combined with mineos_console.js, you can use the retval (error return code) to determine the state of a ton of properties in mineos.

mc@mineos /# cd /usr/games/minecraft/
mc@mineos games/minecraft# chmod +x mineos_console.js
mc@mineos games/minecraft# ./mineos_console.js -s ff -- verify 'up'
[ff] Error executing "verify" because server condition not met: up
mc@mineos games/minecraft# echo $?
1
mc@mineos games/minecraft# ./mineos_console.js -s ff -- verify '!up'
[ff] Successfully executed "verify"
mc@mineos games/minecraft# echo $?
0

The actual stdout can be ignored from your verify command–the key here is the exit code, which is the value behind $?.

All the valid properties you can test are found listed in the ‘properties’ function, listed right above ‘verify’. This way you can easily and programmatically test if servers are exists, or up or not up (!up), get the java_pid, screen_pid…and so forth.

Keep in mind: The truth table is inverted: 0 means ‘no error, what you asked for is true’.

So with [ff] down, up returns 1, and !up returns 0.