LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-31-2004, 10:18 AM   #1
rspurlock
LQ Newbie
 
Registered: Jul 2003
Location: Knoxville, TN
Posts: 13

Rep: Reputation: 0
Script to restart natd and watch it


I'm trying to write either a perl script or shell script to restart natd after a php script adds to the natd.conf file. The problem I've run into is after the script kills the natd process, it has to quess how long to wait before it restarts it. Here's how I'm doing it now:

#!/usr/bin/perl
##Restart NATD
print `kill \`cat /var/run/natd.pid\``;
sleep (20);
print `/sbin/natd -f /etc/natd.conf`;

I need to run a loop that continuously checks for natd to be killed before it tries to run again. Since I'm doing all this remotely it causes major problems if the timing is off and it tries to restart but can't.

#!/bin/ksh
kill \`cat /var/run/natd.pid\`
while true
do
if [ -z $(ps -ef |grep natd | grep -v grep) ] ; then
/sbin/natd -f /etc/natd.conf
fi
done
exit

Will this do the trick? The next question is this: How would I then check to make sure it's restarted, and if it hasn't, have it run natd with a backup config file that's know good? (ie /etc/natd.good)

Help completing this script would be great. Thanks in advance!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL restart script? Fuwex Debian 2 08-17-2005 03:23 PM
run script when restart ust Linux - Software 4 08-25-2004 04:13 PM
Restart script blablaman Linux - Newbie 1 08-20-2004 07:09 AM
bash script for network restart munkeh Programming 8 11-10-2003 06:00 PM
I wants to run the script(xx) while restart the system. help pls... fmohideen76 Linux - General 2 07-11-2002 02:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration