[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

bash functions for daemon control (was Re: [LONG] RH refugee comments & questions)

On Tue, Apr 15, 2003 at 08:41:06PM -0700, Vineet Kumar wrote:
> * Monte Milanuk (milanuk@nwinternet.com) [030415 16:23]:
> > This is one of those things that I'm interested in myself.  In something 
> > like SuSE or RedHat, I'd just go in and issue a command of something 
> > like /etc/rc.d/init.d/nfsserver restart to shut down and restart the 
> > server w/ new config file.   SuSE had a handy shortcut where a body 
> > could just type 'rcnfsserver restart' w/o having to type out the full 
> > path or cd to that directory and do the same thing.  What would be the 
> > equivalent in Debian (of the full path command)?

You could modify /root/.bashrc and add the following:

	# functions for daemon control

	function start { /etc/init.d/$1 start; }
	function stop { /etc/init.d/$1 stop; }
	function restart { /etc/init.d/$1 restart; }
	function reload { /etc/init.d/$1 reload; }

You have to be logged in as root (although, conceivably one could wrap sudo
around these) and then you can just type "reload apache" for example, to force
apache to reload its config files.  

I don't remember where I got these, but I've been using them for several years,
and they make managing daemons much more reasonable.

The only drawback is that when I forget the exact name of a daemon I have to do
an ls /etc/init.d to find out -- I've been meaning to add some form of error
processing that will say something like "syslog not found" followed by a
listing of all contents of the /etc/init.d folder so that I can be reminded
that it's actually sysklogd, not syslog.  Haven't gotten around to that just
yet, however.


Shaun Crossley

Reply to: