LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-08-2005, 10:27 AM   #1
jamiehenderson
LQ Newbie
 
Registered: Jun 2005
Posts: 3

Rep: Reputation: 0
Service to auto restart


Hi there.

I am running Vsftpd on Redhat EL3. The service falls over every now and then, and i am unclear as to why this is happening. I believe there is a way to restart the service if it is to fail. Does anyone know how this is done? Any help would be great.

Cheers,

J.
 
Old 08-08-2005, 10:32 AM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Hi,

This command should restart it
service vsftpd restart
 
Old 08-08-2005, 11:08 AM   #3
jamiehenderson
LQ Newbie
 
Registered: Jun 2005
Posts: 3

Original Poster
Rep: Reputation: 0
That's cool, but i want the service to restart automatically as soon as it dies?
 
Old 08-08-2005, 01:44 PM   #4
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
i an sure i made some typos and this uses "service" not sure every distro has a "service" command
also assumes the vsftpd sctipt can take "status" as an arg
i'm not even sure the process is called "vsftpd" cause i don't use it
but anyway with some debugging and cleaning up/fixing this should work
chmod 755 and make it a start at boot thing i think
Code:
#automated vsftpd check script. Will restart Vsftpd when it's down
#script runs every 30 seconds, checks for pid and  pid file, then if not found
#restarts vsftpd
#!/bin/bash
DATE=`date "+%m%d%y [%k:%M]"`
LOGDATE=`date "+%m-%d-%y [%k:%M:%S]"`
mail=/bin/mail
sysadmin=you@yourdomain.com
vsftpfile=/tmp/vsftpd.txt
logfile=/var/log/vsftpdcheck.log
echo "$LOGDATE - Vsftpd Check Service starting up " >> $logfile
function stopvsftpd
{
/sbin/service vsftpd stop
}
function startvsftpd
{
DATE=`date "+%m%d%y [%k:%M]"`
LOGDATE=`date "+%m-%d-%y [%k:%M:%S]"`
stopvsftpd
echo "Vsftpd Service Down, attempting to restart on $DATE" >> $vsftpdfile
cat $vsftpdfile | $mail -s 'Vsftpd Restart' $sysadmin
/sbin/service vsftpd stop
/sbin/service vsftpd start
rm $vsftpdfile
}
function checkpid
{
DATE=`date "+%m%d%y [%k:%M]"`
LOGDATE=`date "+%m-%d-%y [%k:%M:%S]"`
# ps xua | grep -q vsftpd
/sbin/service vsftpd status |grep "is running..."
if [ $? != 0 ]
then
echo "$LOGDATE - No Vsftpd Running" >> $logfile
startvsftpd
else
echo "$LOGDATE - Normal Vsftpd Running" >> $logfile
fi
}
function quit {
 function quit {
exit
} 
 COUNTER=0
while [  $COUNTER -lt 10 ]; do
checkpid
sleep 30s
done
 
  


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
Automatically Restart Service tulip4heaven Linux - General 1 04-23-2005 02:11 AM
auto restart service st3reo Linux - Newbie 4 12-07-2004 12:46 PM
How to restart a service in slackware? echojihui Slackware 7 08-31-2004 08:03 PM
service network restart perry Linux - Networking 2 12-15-2003 07:00 AM
Auto-login and auto-restart... TankerKevo Red Hat 2 10-04-2003 07:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:03 AM.

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
Open Source Consulting | Domain Registration