The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
AIX Crashed.. pbsrinivas AIX 3 07-12-2007 06:23 PM
old server crashed billfaith UNIX for Dummies Questions & Answers 5 02-01-2007 06:23 AM
Gollum got crashed tayyabq8 Post Here to Contact Site Administrators and Moderators 0 10-22-2006 05:00 AM
kill crashed out users tez Shell Programming and Scripting 2 08-25-2006 07:59 AM
Genome Startmenu crashed why I don't Know ?? atiato UNIX Desktop for Dummies Questions & Answers 1 02-26-2002 08:37 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-01-2005
Phobos Phobos is offline
Registered User
  
 

Join Date: Jan 2005
Location: Columbus, GA
Posts: 61
Restarting a Crashed Process

Hello,
I host a couple of Call of Duty gameing servers. There are some hackers who love the crash them. When they crash them it simply causes a segmentaion fault and kills the PID. I was wondering it you could help me write a script to simply restart the program after it has been crashed. The program works as follows: If you want to start a server you simply type: "./cod_lnxded +exec p31.cfg &" It then creates a backgrounded PID. I have created a script to launch about 10 of these. Now all I want is a script to see if any of these crases and to restart them.

Thanks a million,
Robert
  #2 (permalink)  
Old 05-01-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
use ps -ef | grep "procesname" | grep -v "grep"

if you do n't get any o/p ... start that process in the script.

put this in a loop which checks process status for certain time period.

or setup the cron job.


Before that ...

just have a thought about hackers to your system
  #3 (permalink)  
Old 05-01-2005
Phobos Phobos is offline
Registered User
  
 

Join Date: Jan 2005
Location: Columbus, GA
Posts: 61
yeah...... It would be great if I knew how to do that.

I knew the method I just don't know how to shell script, heh.
  #4 (permalink)  
Old 05-02-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
can you post your start script?
  #5 (permalink)  
Old 05-02-2005
Phobos Phobos is offline
Registered User
  
 

Join Date: Jan 2005
Location: Columbus, GA
Posts: 61
#!/bin/bash

./cod_lnxded +exec sam.cfg &
./cod_lnxded +exec h20war.cfg &
./cod_lnxded +exec cypher.cfg &
./cod_lnxded +exec ryan.cfg &
./cod_lnxded +exec cell.cfg &
./cod_lnxded +exec alls.cfg &
./cod_lnxded +exec p31.cfg &
exit 0
  #6 (permalink)  
Old 05-02-2005
google's Avatar
google google is offline Forum Advisor  
Moderator
  
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
Why did you choose to exit your script? I probably would try something like this:

For each process
Check to see if a process is running based upon your script name
if no process is found
Submit the process in the background
Create a lock file containing the PID value
Determine an appropriate wait interval then poll each process based on the
value contained in the lock file. If the process is no longer running, restart it, otherwise check the next process.

Run the script from a crontab but make sure you only have 1 instance running at a time (again use a lock file for the main script).

Last edited by google; 05-02-2005 at 09:24 PM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:25 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0