Jump to content

server starter


Martyz

Recommended Posts

First you make a .sh script called mtawatch.sh (or whatever you like)

nano mtawatch.sh  

then paste the code in there

 #!/bin/sh 
  
mta="/home/mtaserver/" 
process=`ps uxw | grep mta-server | grep -v grep | awk '{print $11}'` 
  
if [ -z "$process" ]; then 
  
  echo "Couldn't find MTA running, restarting it." 
  cd "$mta" 
  screen -A -m -d -S mta ./mta-server 
  echo "Server Started" 
  
fi  

Edit it to your directories and stuff..

Then on the user your running mta server as, type crontab -e

In a new line, put this code

 * * * * * /home/scripts/mtawatch.sh 

Again, change it to your directories.. also don't forget to chmod +x mtawatch.sh

This script will check if the server is running every minute (minimum time for crontab), and it will start it if it isn't running.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...