[Menu] Private Servers
(25 Dec 13, 11:26PM)Ronald_Reagan Wrote: Thank you for telling me, I will check on that within a day.

Run this script with Cron, every minute. It's a super efficient script, so it won't affect the running of your servers.

#!/bin/sh

# Checks if your AssaultCube servers are up, and if not, attempts to
# reboot them and sends you an e-mail to let you know whether that
# reboot failed or not. Please ensure you've install mailutils:
#
#    sudo apt-get install mailutils
#
# Change all of the below aliases for this to work!

###
# E-mail subject:
ESUBJECT="XYZ SERVER DIED!"
###
# E-mail address:
EMAILADDR="[email protected]"
###

###
# The AC directory (no trailing slash):
THEACDIR="/path/to/AC"
###
# Name of the server executable in bin_unix directory:
NAMEEXEC1="linux_server"
###
# Name of the shell-file to run that restarts your AC server:
ACSHEXEC1="server.sh"
###

###
# Where to place the files for counting fails, which will prevent excessive server restarts.
# Filenames are dated, so files can be arranged by name (no folders per-server required).
# It goes without saying, ensure the directory exists and read/write-permission is available.
#
FILECOUNTDIR="/path/to/where_ever"
###
# FYI: This essentially allows you to log when your server fails, so I suggest not to delete them.
#      however, if you do want to delete them, please uncomment the following line and they'll be
#      deleted once 24 hours old.
#DELETECOUNTFILES="1"
###
###    This script has no log-rotate facility, your server shouldn't be crashing that much!
###
# Name of logfiles (i.e. your servername):
NAMESERV1="AC"
###

# What to write in your e-mail if your reboot was successful:
IFSUC1="Server died, reboot succesful at "$(date +%F-%T)"."
###
# What to write in your e-mail if your reboot was *NOT* successful:
IFFAIL1="Server died. Reboot failed at "$(date +%F-%T)"."
###
# What to write in your e-mail after 3 failed restarts in 12 hours:
IFDONE1="Server died 3x in 12 hours, something is VERY wrong. Please investigate, no further reboots will be done."
###


if [ -z "$(pidof $NAMEEXEC1)" ]; then
  touch "$FILECOUNTDIR"/"$NAMESERV1"-at-"$(date +%F-%H.%M.%S)".fail && sleep 1    # Long version of time, for Windows compatiblity.
  HOWMANYFAILS=`cd "$FILECOUNTDIR" && find ./"$NAMESERV1"* -mmin -720 | wc -l`
  if [ "$HOWMANYFAILS" -le "3" ]; then
    sh "$THEACDIR"/"$ACSHEXEC1"
    sleep 5
    if [ -n "$(pidof $NAMEEXEC1)" ]; then
      echo "$IFSUC1" | mail -s "$ESUBJECT" "$EMAILADDR"
    else
      echo "$IFFAIL1" | mail -s "$ESUBJECT" "$EMAILADDR"
    fi
  elif [ "$HOWMANYFAILS" = "4" ]; then
    echo "$IFDONE1" | mail -s "$ESUBJECT" "$EMAILADDR"
  fi
  if [ "$DELETECOUNTFILES" = "1" ]; then
    cd "$FILECOUNTDIR" && find ./"$NAMESERV1"* -mmin +1440 | xargs rm -f
  fi
fi

(note, this script DOES reinvent the wheel (there are programs in Linux that checks if programs have failed, etc), HOWEVER, the "wheel", is far too complex for my needs... this simple script will do nicely)
Thanks given by:


Messages In This Thread
[Menu] Private Servers - by #M|A#Wolf - 11 Jun 11, 09:04AM
RE: [Menu] Private Servers - by Ronald_Reagan - 11 Jun 11, 11:17AM
RE: [Menu] Private Servers - by V-Man - 11 Jun 11, 11:12PM
RE: [Menu] Private Servers - by #M|A#Wolf - 12 Jun 11, 09:11AM
RE: [Menu] Private Servers - by Viper - 12 Jun 11, 10:54AM
RE: [Menu] Private Servers - by Shorty - 12 Jun 11, 01:44PM
RE: [Menu] Private Servers - by PERROS - 12 Jun 11, 02:14PM
RE: [Menu] Private Servers - by #M|A#Wolf - 12 Jun 11, 05:58PM
RE: [Menu] Private Servers - by HellJanitorIsHispanic - 13 Jun 11, 02:46AM
RE: [Menu] Private Servers - by #M|A#Wolf - 13 Jun 11, 12:11PM
RE: [Menu] Private Servers - by HellJanitorIsHispanic - 13 Jun 11, 01:46PM
RE: [Menu] Private Servers - by Xenon - 13 Jun 11, 03:43PM
RE: [Menu] Private Servers - by #M|A#Wolf - 14 Jun 11, 10:13PM
RE: [Menu] Private Servers - by Duckett - 15 Jun 11, 05:12AM
RE: [Menu] Private Servers - by #M|A#Wolf - 15 Jun 11, 05:26AM
RE: [Menu] Private Servers - by Viper - 15 Jun 11, 07:07AM
RE: [Menu] Private Servers - by Ronald_Reagan - 15 Jun 11, 07:14AM
RE: [Menu] Private Servers - by #M|A#Wolf - 15 Jun 11, 07:47AM
RE: [Menu] Private Servers - by #M|A#Wolf - 16 Jun 11, 10:02AM
RE: [Menu] Private Servers - by #M|A#Wolf - 16 Jun 11, 06:55PM
RE: [Menu] Private Servers - by #M|A#Wolf - 16 Jun 11, 08:47PM
RE: [Menu] Private Servers - by #M|A#Wolf - 17 Jun 11, 01:13AM
RE: [Menu] Private Servers - by Viper - 17 Jun 11, 01:19AM
RE: [Menu] Private Servers - by Ronald_Reagan - 17 Jun 11, 01:28AM
RE: [Menu] Private Servers - by Viper - 17 Jun 11, 01:41AM
RE: [Menu] Private Servers - by castiel - 20 Jun 11, 12:17PM
RE: [Menu] Private Servers - by #M|A#Wolf - 23 Jun 11, 08:50PM
RE: [Menu] Private Servers - by #M|A#Wolf - 06 Jul 11, 09:16PM
RE: [Menu] Private Servers - by castiel - 23 Jul 11, 10:26AM
RE: [Menu] Private Servers - by Duckett - 23 Jul 11, 10:58AM
RE: [Menu] Private Servers - by #M|A#Wolf - 24 Jul 11, 03:20AM
RE: [Menu] Private Servers - by castiel - 27 Jul 11, 07:44AM
RE: [Menu] Private Servers - by DES|Anderson - 27 Jul 11, 08:25AM
RE: [Menu] Private Servers - by Fate - 27 Jul 11, 11:52AM
RE: [Menu] Private Servers - by Bukz - 27 Jul 11, 11:10AM
RE: [Menu] Private Servers - by DES|Anderson - 27 Jul 11, 11:57AM
RE: [Menu] Private Servers - by #M|A#Wolf - 12 Aug 11, 07:07PM
RE: [Menu] Private Servers - by #M|A#Wolf - 28 Dec 11, 02:02AM
RE: [Menu] Private Servers - by ikljo - 28 Dec 11, 02:27AM
RE: [Menu] Private Servers - by Murmer - 28 Dec 11, 02:51AM
RE: [Menu] Private Servers - by OpenSource - 28 Dec 11, 03:54AM
RE: [Menu] Private Servers - by #M|A#Wolf - 28 Dec 11, 03:25AM
RE: [Menu] Private Servers - by #M|A#Wolf - 14 Apr 12, 09:51PM
RE: [Menu] Private Servers - by D1551D3N7 - 14 Apr 12, 10:43PM
RE: [Menu] Private Servers - by #M|A#Wolf - 14 Apr 12, 10:53PM
RE: [Menu] Private Servers - by Edward - 14 Apr 12, 11:15PM
RE: [Menu] Private Servers - by D1551D3N7 - 14 Apr 12, 11:17PM
RE: [Menu] Private Servers - by Cemer - 15 Apr 12, 02:08AM
RE: [Menu] Private Servers - by #M|A#Wolf - 06 Jul 12, 05:41AM
RE: [Menu] Private Servers - by Oracle - 06 Jul 12, 07:10AM
RE: [Menu] Private Servers - by #M|A#Wolf - 06 Jul 12, 07:40AM
RE: [Menu] Private Servers - by Xenon - 06 Jul 12, 12:51PM
RE: [Menu] Private Servers - by #M|A#Wolf - 06 Jul 12, 07:01PM
RE: [Menu] Private Servers - by Link - 06 Jul 12, 07:48PM
RE: [Menu] Private Servers - by Xenon - 07 Jul 12, 07:24AM
RE: [Menu] Private Servers - by #M|A#Wolf - 23 Jul 12, 10:29AM
RE: [Menu] Private Servers - by Bukz - 25 Jul 12, 03:37AM
RE: [Menu] Private Servers - by bballn45 - 25 Jul 12, 04:22AM
RE: [Menu] Private Servers - by #M|A#Wolf - 25 Jul 12, 05:38AM
RE: [Menu] Private Servers - by Bukz - 25 Jul 12, 06:09AM
RE: [Menu] Private Servers - by #M|A#Wolf - 25 Jul 12, 06:17AM
RE: [Menu] Private Servers - by Bukz - 25 Jul 12, 06:31AM
RE: [Menu] Private Servers - by #M|A#Wolf - 25 Jul 12, 07:09AM
RE: [Menu] Private Servers - by Bukz - 25 Jul 12, 07:18AM
RE: [Menu] Private Servers - by #M|A#Wolf - 25 Jul 12, 07:36AM
RE: [Menu] Private Servers - by blueberry - 25 Jul 12, 08:14AM
RE: [Menu] Private Servers - by Million - 25 Jul 12, 09:29AM
RE: [Menu] Private Servers - by #M|A#Wolf - 25 Jul 12, 06:29PM
RE: [Menu] Private Servers - by paulmuaddibKA - 26 Jul 12, 01:32AM
RE: [Menu] Private Servers - by Vermi - 26 Jul 12, 10:25AM
RE: [Menu] Private Servers - by #M|A#Wolf - 02 Aug 12, 08:23PM
RE: [Menu] Private Servers - by #M|A#Wolf - 02 Aug 12, 10:33PM
RE: [Menu] Private Servers - by paulmuaddibKA - 02 Aug 12, 10:36PM
RE: [Menu] Private Servers - by #M|A#Wolf - 02 Aug 12, 10:39PM
RE: [Menu] Private Servers - by Jg99 - 02 Aug 12, 10:44PM
RE: [Menu] Private Servers - by X-Ray_Dog - 02 Aug 12, 11:29PM
RE: [Menu] Private Servers - by Jg99 - 03 Aug 12, 02:12AM
RE: [Menu] Private Servers - by paulmuaddibKA - 03 Aug 12, 12:02AM
RE: [Menu] Private Servers - by Edward - 03 Aug 12, 12:11AM
RE: [Menu] Private Servers - by Oracle - 03 Aug 12, 12:12AM
RE: [Menu] Private Servers - by #M|A#Wolf - 03 Aug 12, 11:32PM
RE: [Menu] Private Servers - by 1Cap - 04 Aug 12, 12:38AM
RE: [Menu] Private Servers - by Jg99 - 04 Aug 12, 05:54AM
RE: [Menu] Private Servers - by blueberry - 25 Aug 12, 04:40AM
RE: [Menu] Private Servers - by #M|A#Wolf - 03 Sep 12, 01:51AM
RE: [Menu] Private Servers - by DogDancing - 04 Sep 12, 12:06AM
RE: [Menu] Private Servers - by HarDZi!nN+ - 04 Sep 12, 01:39PM
RE: [Menu] Private Servers - by Edward - 04 Sep 12, 01:43PM
RE: [Menu] Private Servers - by HarDZi!nN+ - 04 Sep 12, 01:50PM
RE: [Menu] Private Servers - by Orynge - 04 Sep 12, 03:05PM
RE: [Menu] Private Servers - by 888 - 05 Sep 12, 10:04AM
RE: [Menu] Private Servers - by Bukz - 05 Sep 12, 01:16PM
RE: [Menu] Private Servers - by Milandrag - 05 Sep 12, 04:44PM
RE: [Menu] Private Servers - by blueberry - 20 Oct 12, 11:22PM
RE: [Menu] Private Servers - by #M|A#Wolf - 20 Oct 12, 11:24PM
RE: [Menu] Private Servers - by blueberry - 20 Oct 12, 11:30PM
RE: [Menu] Private Servers - by Cemer - 21 Oct 12, 12:07AM
RE: [Menu] Private Servers - by blueberry - 21 Oct 12, 12:31AM
RE: [Menu] Private Servers - by #M|A#Wolf - 21 Oct 12, 12:36AM
RE: [Menu] Private Servers - by blueberry - 21 Oct 12, 01:15AM
RE: [Menu] Private Servers - by Z3R0 - 21 Oct 12, 02:01AM
RE: [Menu] Private Servers - by Xenon - 21 Oct 12, 02:47AM
RE: [Menu] Private Servers - by Cemer - 21 Oct 12, 04:29AM
RE: [Menu] Private Servers - by Xenon - 21 Oct 12, 05:57AM
RE: [Menu] Private Servers - by blueberry - 17 Nov 12, 10:28PM
RE: [Menu] Private Servers - by Noobicus - 19 Nov 12, 06:19PM
RE: [Menu] Private Servers - by #M|A#Wolf - 17 Nov 12, 11:22PM
RE: [Menu] Private Servers - by #M|A#Wolf - 01 Mar 13, 01:45AM
RE: [Menu] Private Servers - by Skinny-Dog - 01 Mar 13, 02:23AM
RE: [Menu] Private Servers - by PhaNtom - 14 Mar 13, 03:49PM
RE: [Menu] Private Servers - by SaXzE - 14 Mar 13, 06:55PM
RE: [Menu] Private Servers - by #M|A#Wolf - 23 Apr 13, 04:09AM
RE: [Menu] Private Servers - by DrauL - 23 Apr 13, 04:31AM
RE: [Menu] Private Servers - by #M|A#Wolf - 24 Apr 13, 03:38AM
RE: [Menu] Private Servers - by DrauL - 24 Apr 13, 03:58AM
RE: [Menu] Private Servers - by #M|A#Wolf - 24 Apr 13, 05:04AM
RE: [Menu] Private Servers - by Brutal System - 01 May 13, 06:22PM
RE: [Menu] Private Servers - by #M|A#Wolf - 01 May 13, 06:35PM
RE: [Menu] Private Servers - by PhaNtom - 01 May 13, 06:41PM
RE: [Menu] Private Servers - by Brutal System - 01 May 13, 06:50PM
RE: [Menu] Private Servers - by #M|A#Wolf - 01 May 13, 07:02PM
RE: [Menu] Private Servers - by #M|A#Wolf - 16 May 13, 11:41PM
RE: [Menu] Private Servers - by PhaNtom - 16 May 13, 11:56PM
RE: [Menu] Private Servers - by DrauL - 17 May 13, 04:52AM
RE: [Menu] Private Servers - by #M|A#Wolf - 17 May 13, 06:23AM
RE: [Menu] Private Servers - by DrauL - 17 May 13, 07:23AM
RE: [Menu] Private Servers - by #M|A#Wolf - 18 May 13, 03:54AM
RE: [Menu] Private Servers - by Luc@s - 02 Jun 13, 12:41PM
RE: [Menu] Private Servers - by #M|A#Wolf - 23 Jun 13, 03:22AM
RE: [Menu] Private Servers - by Luc@s - 23 Jun 13, 11:49AM
RE: [Menu] Private Servers - by DrauL - 23 Jun 13, 04:59PM
RE: [Menu] Private Servers - by Krayce - 23 Jun 13, 06:53PM
RE: [Menu] Private Servers - by X-Ray_Dog - 23 Jun 13, 07:42PM
RE: [Menu] Private Servers - by Bukz - 23 Jun 13, 08:08PM
RE: [Menu] Private Servers - by jamz - 23 Jun 13, 08:26PM
RE: [Menu] Private Servers - by PhaNtom - 23 Jun 13, 11:51PM
RE: [Menu] Private Servers - by Mr.OpTic - 24 Jun 13, 01:30AM
RE: [Menu] Private Servers - by #M|A#Wolf - 24 Jun 13, 06:24AM
RE: [Menu] Private Servers - by DrauL - 24 Jun 13, 06:45AM
RE: [Menu] Private Servers - by #M|A#Wolf - 29 Jun 13, 07:12PM
RE: [Menu] Private Servers - by #M|A#Wolf - 05 Jul 13, 11:12PM
RE: [Menu] Private Servers - by Oracle - 05 Jul 13, 11:40PM
RE: [Menu] Private Servers - by #M|A#Wolf - 05 Jul 13, 11:50PM
RE: [Menu] Private Servers - by #M|A#Wolf - 10 Jul 13, 02:23AM
RE: [Menu] Private Servers - by #M|A#Wolf - 11 Jul 13, 02:37AM
RE: [Menu] Private Servers - by PhaNtom - 08 Aug 13, 08:09PM
RE: [Menu] Private Servers - by #M|A#Wolf - 08 Aug 13, 09:58PM
RE: [Menu] Private Servers - by PhaNtom - 08 Aug 13, 10:02PM
RE: [Menu] Private Servers - by RandumKiwi - 01 Dec 13, 03:12AM
RE: [Menu] Private Servers - by #M|A#Wolf - 01 Dec 13, 05:51AM
RE: [Menu] Private Servers - by Bukz - 01 Dec 13, 07:16AM
RE: [Menu] Private Servers - by D3M0NW0LF - 01 Dec 13, 07:28AM
RE: [Menu] Private Servers - by #M|A#Wolf - 24 Dec 13, 03:22AM
RE: [Menu] Private Servers - by RandumKiwi - 24 Dec 13, 07:40AM
RE: [Menu] Private Servers - by X-Ray_Dog - 24 Dec 13, 08:56AM
RE: [Menu] Private Servers - by jamz - 24 Dec 13, 09:57AM
RE: [Menu] Private Servers - by Million - 24 Dec 13, 10:34AM
RE: [Menu] Private Servers - by MotoShadow - 24 Dec 13, 02:54PM
RE: [Menu] Private Servers - by Vanquish - 24 Dec 13, 03:02PM
RE: [Menu] Private Servers - by RandumKiwi - 24 Dec 13, 07:46PM
RE: [Menu] Private Servers - by Ronald_Reagan - 24 Dec 13, 07:49PM
RE: [Menu] Private Servers - by #M|A#Wolf - 25 Dec 13, 12:54AM
RE: [Menu] Private Servers - by Ronald_Reagan - 25 Dec 13, 11:26PM
RE: [Menu] Private Servers - by Casius - 25 Dec 13, 11:58PM
RE: [Menu] Private Servers - by RandumKiwi - 26 Dec 13, 01:14AM
RE: [Menu] Private Servers - by Casius - 26 Dec 13, 01:31AM
RE: [Menu] Private Servers - by Ronald_Reagan - 26 Dec 13, 03:13AM
RE: [Menu] Private Servers - by #M|A#Wolf - 26 Dec 13, 04:49AM
RE: [Menu] Private Servers - by Million - 19 Oct 14, 07:16PM
RE: [Menu] Private Servers - by Million - 19 Oct 14, 10:03PM
RE: [Menu] Private Servers - by Luc@s - 11 Jan 14, 12:51PM
RE: [Menu] Private Servers - by Vanquish - 19 Oct 14, 08:10PM
RE: [Menu] Private Servers - by Todesgurke - 19 Oct 14, 08:28PM
RE: [Menu] Private Servers - by X-Ray_Dog - 19 Oct 14, 08:48PM
RE: [Menu] Private Servers - by +f0r3v3r+ - 23 Oct 14, 06:33AM
RE: [Menu] Private Servers - by Orynge - 23 Oct 14, 09:20AM
RE: [Menu] Private Servers - by Marti - 23 Oct 14, 11:22AM
RE: [Menu] Private Servers - by stef - 23 Oct 14, 01:57PM
RE: [Menu] Private Servers - by Million - 23 Oct 14, 02:52PM
RE: [Menu] Private Servers - by stef - 23 Oct 14, 05:36PM
RE: [Menu] Private Servers - by ExodusS - 23 Oct 14, 06:50PM
RE: [Menu] Private Servers - by +f0r3v3r+ - 23 Oct 14, 10:07PM
RE: [Menu] Private Servers - by stef - 24 Oct 14, 12:55AM
RE: [Menu] Private Servers - by +f0r3v3r+ - 24 Oct 14, 02:33AM
RE: [Menu] Private Servers - by Halte - 25 Oct 14, 10:28AM
RE: [Menu] Private Servers - by +f0r3v3r+ - 26 Oct 14, 04:07AM
RE: [Menu] Private Servers - by HoeHunter - 26 Oct 14, 11:52PM
RE: [Menu] Private Servers - by vonunov - 13 Dec 14, 06:03AM
RE: [Menu] Private Servers - by +f0r3v3r+ - 13 Dec 14, 09:04AM
RE: [Menu] Private Servers - by Mhtsos - 18 Dec 14, 09:45PM
RE: [Menu] Private Servers - by Mousikos - 19 Dec 14, 12:36AM
RE: [Menu] Private Servers - by Million - 05 Jan 15, 10:29PM
RE: [Menu] Private Servers - by +f0r3v3r+ - 22 Jan 15, 03:00AM
RE: [Menu] Private Servers - by Million - 13 Jun 15, 06:29PM
RE: [Menu] Private Servers - by Marti - 13 Jun 15, 06:52PM
RE: [Menu] Private Servers - by Million - 13 Jun 15, 07:10PM
RE: [Menu] Private Servers - by Mhtsos - 02 Jul 15, 02:18PM
RE: [Menu] Private Servers - by Million - 02 Jul 15, 03:02PM
RE: [Menu] Private Servers - by Marti - 02 Jul 15, 02:22PM
RE: [Menu] Private Servers - by Timber - 02 Jul 15, 04:08PM
RE: [Menu] Private Servers - by Million - 02 Jul 15, 05:24PM
RE: [Menu] Private Servers - by #M|A#Wolf - 02 Jul 15, 07:24PM
RE: [Menu] Private Servers - by Marti - 02 Jul 15, 07:48PM
RE: [Menu] Private Servers - by +f0r3v3r+ - 25 Sep 16, 06:58PM