Skip to content

Instantly share code, notes, and snippets.

@magnetik
Last active August 29, 2015 14:13
Show Gist options
  • Save magnetik/83e144959a73e9ce8b50 to your computer and use it in GitHub Desktop.
Save magnetik/83e144959a73e9ce8b50 to your computer and use it in GitHub Desktop.
Script to auto restart server after a certain duration (like 20 days)
#!/bin/bash
SERVER_DIRECTORY="/opt/maniaplanet-server/"
SERVER_TIMEOUT="298h" #298h ~= 12.4d
if [ "$(groups | grep games)" ];
then
cd $SERVER_DIRECTORY
while true; do
timeout --foreground $SERVER_TIMEOUT ./ManiaPlanetServer "$@"
RETVAL=$?
if [[ $RETVAL -ne 124 ]]; then
break
fi
done
exec
else
echo "You are not member of the group 'games'"
echo "Please type :"
echo "sudo usermod -a -G games <username>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment