Discussion:
Start and stop the samba server
Robert
2003-12-01 17:10:49 UTC
Permalink
Is there a good way to stop and restart the samba server...
for example to have it re read the smb.conf, without rebooting the
actual pc?

if I should kill a process should I kill them all ??? if so is there an
efficent way to do this?

thanks in advance
Robert
Tony Nugent
2003-12-01 17:10:49 UTC
Permalink
Post by Robert
Is there a good way to stop and restart the samba server...
for example to have it re read the smb.conf, without rebooting the
actual pc?
You don't need or want to reboot just for things like this! This is the
world of unix, not m$'s world of "do you wish to reboot now?" :)
Post by Robert
if I should kill a process should I kill them all ??? if so is there an
efficent way to do this?
You don't even need to kill and restart the processes (although this will
certainly work and is far better than doing a reboot).

In fact, (if I read what I thought I read), the samba daemons periodically
reread the config files anyway.

But to force most processes to re-read there config files, give them a
SIGHUP signal...

% killall -HUP smbd nmbd

Cheers
Tony
PayPC System Mail Subscriber
2003-12-01 17:10:49 UTC
Permalink
Post by Robert
Is there a good way to stop and restart the samba server...
for example to have it re read the smb.conf, without rebooting the
actual pc?
if I should kill a process should I kill them all ??? if so is there an
efficent way to do this?
Heheheh, you guys should read your unix command line help. :) The command
you want is:

killall -HUP smbd

killall kills (or sends the specified signal) to all exectuables which the
specified name.

I've never had problems just SIGTERM'ing (no signal specified to
kill/killall) smbd's on "live" sessions. The only problem I'd envisage would
be with oplocked files (smbstatus is your friend!).... in which case -HUP
would be the preferred technique - though the changes aren't applied to
already-established sessions. It sounds like samba automagically re-reads
its smb.conf anyhow; I excerpt from the current samba man page:

The configuration file, and any files that it includes,
are automatically reloaded every minute, if they change.
You can force a reload by sending a SIGHUP to the server.
Reloading the configuration file will not affect connec-
tions to any service that is already established. Either
the user will have to disconnect from the service, or smbd
killed and restarted.

So if you have a "dead time" auto-logout (as I do), the changes will be
picked up eventually. If you wish to force an immediate change, than
SIGTERMing the sessions is the only way (that is, kill/killall without a
specified signal name).

Ya know, every time I install/radically alter/remove vital system services
from my always-busy intranet server box without having to run for another cd,
reboot multiple times, or experience any downtime or interruption of service
whatsoever, I thank whatever wisdom resides within me which prodded me into
deep-sixing my NT4 servers. (We also manage to get one box to do what
required two boxes to perform satisfactorily, and then some.).

=Rob=
Christophe Dumont
2003-12-01 17:10:50 UTC
Permalink
This is a simple script that kill every process linked to samba, and run
samba again.

kill -KILL `ps -ef | grep samba | awk '{print $2}'` 2>/dev/null
/usr/local/samba/bin/smbd -D
/usr/local/samba/bin/nmbd -D


But, if you change the smb.conf file, samba will re-read it with no problem.

-C. Dumont
Christopher Kranz
2003-12-01 17:10:51 UTC
Permalink
Post by Christophe Dumont
This is a simple script that kill every process linked to samba, and run
samba again.
kill -KILL `ps -ef | grep samba | awk '{print $2}'` 2>/dev/null
/usr/local/samba/bin/smbd -D
/usr/local/samba/bin/nmbd -D
I have discovered that if you kill the smbd and nmdb processes that have the
parent process id of 1, all the child processes go away as well. At least
this has been my experience with Solaris 2.5.1.
Post by Christophe Dumont
But, if you change the smb.conf file, samba will re-read it with no problem.
Hmm, this may be true for any new connections that are made after you change
smb.conf but what about existing connections? My understanding is that
established connections will not see the changes. This may be important if
you are changing something like 'allow hosts', 'dead time', or 'socket
options'. Anyone know for sure?

Chris
--
Christopher Kranz | Systems Programmer | ***@CS.Princeton.EDU
35 Olden St., Room 211 | Computer Science Dept. | Voice: 609-258-1747
Princeton, NJ 08544-2087 | Princeton University | FAX: 609-258-1771
==========================PGP V2.6.2 key available=======================
"I may make you feel but I can't make you think" - Ian Anderson
amobbs at plasmon.co.uk ()
2003-12-01 17:10:50 UTC
Permalink
Post by Tony Nugent
But to force most processes to re-read there config files, give them a
SIGHUP signal...
% killall -HUP smbd nmbd
The person asking the question only said he was on a PC, not that he was
running Linux. Under Solaris, and most other unices, that command would
have unfortunate consequences.

(Actually, as given, it'd only print a usage message, but a naive user
might persevere until they managed to kill all processes on their machine).

Please don't assume that all UN*X PCs are running Linux.

--
Andrew Mobbs - Software Engineer
Allstor Software Ltd.
Continue reading on narkive:
Loading...