Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-04-2008, 02:01 AM   #1
Registered: May 2005
Posts: 34

Rep: Reputation: 15
Restart a service automatically

Hi all
I wanna know, is there a way to restart a service automatically when sth killed it's related process? E.G, consider that I wanna have my vsftpd always running, and if something stopped it, Linux start it again automatically.
Old 09-04-2008, 02:27 AM   #2
Registered: Oct 2006
Posts: 55

Rep: Reputation: 15
Your best bet is to run a script that checks for the processes and put it in the crontab to run and check every few minutes (depending on the needs).

I'm thinking somewhere like "ps -e" and testing whether the service is active.

If you use Fedora, you can also use /sbin/service <servicename> status to show the status of the service.

There are different ways to do this, but I can't write the script for you right now, sorry. But I'm sure there are plenty of guys here who can ^^
Old 09-04-2008, 03:05 AM   #3
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
If the service is controlled by xinetd, then another instance is started each time a new connection if made. Check how vsftp is run.

It may be started normally in runlevels 3 and 5 but have an /etc/xinetd.d/vsftpd configuration file as well.

If so, you could run "sudo /sbin/chkconfig vsftpd off" and then "sudo /sbin/chkconfig vsftpd xinetd".
The second entry will simply delete the "disable = yes" line which you could do yourself.
# default: off
# description:
#   The vsftpd FTP server serves FTP connections. It uses
#   normal, unencrypted usernames and passwords for authentication.
# vsftpd is designed to be secure.
# NOTE: This file contains the configuration for xinetd to start vsftpd.
#       the configuration file for vsftp itself is in /etc/vsftpd.conf
service ftp
        socket_type             = stream
        protocol                = tcp
        wait                    = no
        user                    = root
        server                  = /usr/sbin/vsftpd
#        server_args             =
#        log_on_success          += DURATION USERID
#        log_on_failure          += USERID
#        nice                    = 10


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
what is the difference between service network reload and service network restart ? markraem Linux - Networking 3 11-21-2007 03:08 PM
How do I set the regulatory daemon to restart when I restart the network service? zahadumy Linux - Networking 0 11-05-2006 11:24 AM
Automatically Restart Service tulip4heaven Linux - General 1 04-23-2005 02:11 AM
Way to automatically restart a program? AlexV Linux - General 1 04-13-2005 05:23 PM
Automatically Restart Server?? flamesrock Linux - Software 4 08-07-2004 09:25 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:22 PM.

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