Jump to content

Restarter for Linux Servers


Recommended Posts

have nobody a script for me ;(

i have search along time, and found 2 scripts.

Now i have a question: can i use them for MTA:DM and when yes how can i use the scripts?

is this for a cronejob? sorry i am a beginner in this stuff

Now here is the first script i found

by Nutz on Wed Oct 13, 2004 3:55 pm

This is the script I use to start mta, save logfiles and automatically restart when

it dies (or is killed):

#!/bin/sh 
log=watchdog.log 
dat=`date` 
mtavc="/home/mta/mtavc/MTAServer0.4.1" 
  
echo "${dat} watchdog script starting." >>${log} 
while true 
do 
  if [ `ps -ax | grep -c '/home/mta/mtavc/MTAServer0.4.1'` -eq 0 ] 
  then 
    echo "${dat} Server exited, restarting..." >>${log} 
    datstr=`date "+%Y-%m-%d-%H%M%S"` 
    mv mtaserver.log ${datstr}.log 
    ${mtavc} >/dev/null 2>&1 & 
  fi 
  sleep 30  
done 

and here is the second script i found

by Stickybit on Sun Feb 08, 2004 9:18 am

Hi Guys

Having installed the server program on a linux server.. i realized the the program needed some kind of startup script... so I wrote one: /sbin/mta. here is the simple code:

#!/usr/bin/perl 
  
  
use English; 
  
  
die "\nYou must be root in order to start the MTA server.\n\n" if ($EFFECTIVE_USER_ID != 0); 
die "\nUsage: $PROGRAM_NAME {start|stop}\n\n" if (!(($ARGV[0] eq 'start') or ($ARGV[0] eq 'stop'))); 
  
  
$action = $ARGV[0]; 
$user   = 'mta'; 
$dir    = '/opt/MTAServer-0.3/'; 
$bin    = 'MTAServer0.3'; 
  
  
CASE: { 
  
   ($action eq 'start') && do { 
  
      print "\nStarting MTA daemon.\n\n"; 
      chdir($dir); 
      system('sudo -u '. $user .' '. $dir . $bin .' -b') == 0 or die "Error while starting server.\n"; 
      last CASE; 
  
   }; 
  
   ($action eq 'stop') && do { 
  
      print "\nStopping MTA daemon.\n\n"; 
      exec ('ps -C '. $bin .' -o pid= | xargs kill -9') == 0 or die "Error while stopping server.\n"; 
      last CASE; 
  
   }; 
  
} 
  

Before you can use this script.. you must create a non-priveleged user called "mta"... and alter the content of $dir to reflect your MTA install directory. For increased security, I have set these permissions on the files:

-rw------- 1 mta mta 0 Oct 26 17:31 banned.lst

-rw------- 1 mta mta 1417 Dec 31 02:46 CHANGELOG

-rw------- 1 mta mta 49 Feb 8 11:02 motd.txt

-rwx------ 1 mta mta 178897 Dec 31 20:32 MTAServer0.3

-rw------- 1 mta mta 8489 Feb 8 11:00 mtaserver.conf

-rw------- 1 mta mta 3092 Dec 31 02:48 README

That was my 50 cent. Thanks for a great program. :)

-Sticky bit

Pleas answer! its realy needed ;(

//EDIT:

now we use a windows server

Now i delet this thread from my favorites, thx 4 help :lol:

Link to comment
  • Recently Browsing   0 members

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