Skip to content

Instantly share code, notes, and snippets.

@maxpert
Created August 20, 2016 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxpert/a15f46b0a91de6cea5f7cb7bd0abad90 to your computer and use it in GitHub Desktop.
Save maxpert/a15f46b0a91de6cea5f7cb7bd0abad90 to your computer and use it in GitHub Desktop.
A restart server shell script that daemonizes any
#!/bin/bash
server_id=`cat server.pid`
if kill -9 $server_id > /dev/null 2>&1; then
echo "Server killed" >&2
fi
# start and banground server here
./server > /dev/null 2>&1 &
echo $! > server.pid
server_id=`cat server.pid`
echo "Started server with PID $server_id"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment