Hi list,
Watching the thread about startup script I thought of a question about
shutdown script. Is it necessary to shutdown certain services when
machine goes down? Like for example mysql, dovecot, clamav, amavis or
openvpn. I've never saw anybody do that. Lots of people on their
manuals, tutorials or posts writes how to start mysql, but none of then
writes a shutdown script. So maybe it is not so necessary? (But then
again, mysql is a database engine, and databases should be handle with
care).
any software which requires special shutdown handling ist busted.
all processes get a SIGTERM on shutdown. the ones that need to do
cleanup before they exit need to install a signal handler for that (and
in general they do).--
Henning Brauer, hb@bsws.de, henning@openbsd.org
BS Web Services, http://bsws.de
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting - Hamburg & Amsterdam
Pardon the ignorant question.
By what method is shutdown then forced to wait until said processes have
cleaned up? Is a response expected by shutdown from the daemon as a
result to sending SIGTERM?Regards,
-Lars
None. rc.shutdown is for those processes with slow/important shutdown
that needs waiting for.---
Lars Hansson
Ok. So then rc.shutdown should be sure to poll the processes until they
are dead.
$ man rc.shutdown
Up to you. I shut down almost all daemons in it. Again, you can call
your own scripts, e.g:echo -n ' mailman'
/usr/local/lib/mailman/bin/mailmanctl -q stop
sleep 30echo -n ' mailgraph'
/usr/local/site/sbin/mailgraphctl stop > /dev/nullecho -n ' squid'
/usr/local/sbin/squid -k shutdownecho -n ' dovecot'
pkill dovecotecho -n ' apache'
apachectl stopecho -n ' postfix'
/usr/local/site/sbin/postfixctl stopecho -n ' viagrad'
su -m _viagrad /usr/local/site/libexec/viagrad/viagrad stopecho -n ' named'
rndc stopecho '.'
Thanks, I will start using rc.shutdown more often :)
At least MySQL should have told you how to shutdown when installing it.
rc.shutdown(8)
Yes, it should have, but it haven't :) So I've got wondering :)
Julian Leyh wrote:
On 14:48 Wed 19 Sep , Tomas wrote:
Hi list,
Watching the thread about startup script I thought of a question about
shutdown script. Is it necessary to shutdown certain services when machine
goes down? Like for example mysql, dovecot, clamav, amavis or openvpn. I've
never saw anybody do that. Lots of people on their manuals, tutorials or
posts writes how to start mysql, but none of then writes a shutdown script.
So maybe it is not so necessary? (But then again, mysql is a database
engine, and databases should be handle with care).At least MySQL should have told you how to shutdown when installing it.
rc.shutdown(8)
Very few, I'd wager. The only ones I bother with doing it for are
postgresql and mysql since it can take them a while to shut down
correctly and it can get messy if they're not.---
Lars Hansson
And can I ask how do you do it? Because I don't want to write my mysql
password in rc.shutdown script.Lars Hansson wrote:
On 9/19/07, Tomas <s.tomas@gmail.com> wrote:
Is it necessary to shutdown certain services when
machine goes down?Very few, I'd wager. The only ones I bother with doing it for are
postgresql and mysql since it can take them a while to shut down
correctly and it can get messy if they're not.---
Lars Hansson
Try: /usr/local/share/mysql/mysql.server stop
Write a script /root/sbin/mysql-shutdown.sh with whatever you need in
it, & call that script from /etc/rc.shutdownOnly root can read it.
Or:
/usr/local/site/sbin/mysql-shutdown.sh
chmod it 0770, and chown it root:dba so that anyone in the dba group can
edit (passwd changes) and run the script.
Hi,
yes, You are right - proper shutdown is important. This functionality
realizes script /etc/rc.shutdown fired during shutdown. I that place should
be commands for all services which require shutdown command.
I hope it is what You looking for ;) (sorry if it is to obvious true for
You).Best regards,
Artur
Yes it's obvious :) But I've got a little bit confused because I've seen
very few using it. But that's already my problem, isn't it? :) Thanks :)Artur Litwinowicz wrote:
Hi,
yes, You are right - proper shutdown is important. This functionality
realizes script /etc/rc.shutdown fired during shutdown. I that place should
be commands for all services which require shutdown command.
I hope it is what You looking for ;) (sorry if it is to obvious true for
You).Best regards,
ArturOn Wed, 19 Sep 2007 14:48:54 +0300, Tomas <s.tomas@gmail.com> wrote:
Hi list,
Watching the thread about startup script I thought of a question about
shutdown script. Is it necessary to shutdown certain services when
machine goes down? Like for example mysql, dovecot, clamav, amavis or
openvpn. I've never saw anybody do that. Lots of people on their
manuals, tutorials or posts writes how to start mysql, but none of then
writes a shutdown script. So maybe it is not so necessary? (But then
again, mysql is a database engine, and databases should be handle with
care).
For most things, there's no need to worry at all.
From http://dev.mysql.com/doc/refman/5.0/en/server-shutdown.html,
mysql does a controlled shutdown when it receives SIGTERM.Examining the code of halt(8) (in src/sbin/reboot), at normal shutdown
SIGTERM is sent to running processes, then a delay of 2 seconds before
a sync(2), then a delay of 3 seconds followed by SIGKILL to anything
still running.So the question is, whether mysql has enough time to shut down
before it's killed. If you think it doesn't, you might like to add
something like 'pkill mysqld; sleep 10' to rc.shutdown. (No need
for some 'mysqladmin shutdown' which would mean listing a plain-
text password in the file).
Thank you so much Stuart for your reply :-)
I have a similar doubt.
What happens when I have a lot of windows open in my fvwm2 and I click
on my desktop and click "Exit Fvwm2" ?Will all the X11 applications be shutdown decently?
Or is it better to type "halt" in an xterm?
What is the right way to shutdown a desktop?Thank you so much once again :-)
Kind regards
Siju
There are some mechanisms to tell applications to shutdown when you
quit X (either by exiting the window manager, or more brutally with
Ctl+Alt+Backspace). They are a bit complex, and no all applications
handle the events they get. (and not all window managers implement the
same protocol).For instance in my experience, firefox manages to remove its lock (in
~/.mozilla/firefox/hexstuff/) most of the time when I exit from X
(using Ctl+Alt+Backspace) without quitting it first.But the safest way is to quit each application 1st, then exit the
window manager. Of course this is mainly important for applications
with pending changes like text editors, e-mail clients, or such.
xclock or xload don't care if they are terminated badly.
Stuart Henderson wrote:
On 2007/09/19 14:48, Tomas wrote:
Watching the thread about startup script I thought of a question about
shutdown script. Is it necessary to shutdown certain services when machine
goes down? Like for example mysql, dovecot, clamav, amavis or openvpn. I've
never saw anybody do that.For most things, there's no need to worry at all.
>From http://dev.mysql.com/doc/refman/5.0/en/server-shutdown.html ,
mysql does a controlled shutdown when it receives SIGTERM.Examining the code of halt(8) (in src/sbin/reboot), at normal shutdown
SIGTERM is sent to running processes, then a delay of 2 seconds before
a sync(2), then a delay of 3 seconds followed by SIGKILL to anything
still running.So the question is, whether mysql has enough time to shut down
before it's killed. If you think it doesn't, you might like to add
something like 'pkill mysqld; sleep 10' to rc.shutdown. (No need
for some 'mysqladmin shutdown' which would mean listing a plain-
text password in the file).That's an excelent idea. I will use 'pkill mysqld'. But instead of 'sleep 10' myabe it's better to check every second if mysqld.sock exists?
I would choose to limit the maximum time, in case mysqld deadlocks.
I think "pgrep mysqld" is a safer test than mysqld.sock (unless
you've read mysql code and determined that the control socket is
only removed after the tables have been flushed).
Something you should be aware of:
If there is insufficient space, MySQL will wait patiently for the
space to become available at which point it picks up like there
never was a problem.
Current behavior may be different. YMMV etc.
Surprising, but it can allow manipulation in low-disk situations.
I've no idea what happens to pending transactions (non-MyISAM databases)
I myself can't say if it's necessary, but it is probably good practice.
I do notice that OpenBSD does not use anything similar to System V
runlevels (which may or may not be good to avoid) but does provide
/etc/rc.shutdown:Checking on my systems, I see that none of the packages that run daemons
use it, even the ones installed from the official packages and ports.
In fact, rc.shutdown appears completely empty. Perhaps you have found
an error / oversight?Regards,
-Lars
That's a good practice. There's no doubt about it. But like I said I've
seen very few people using it, in fact I saw it only once, shuting down
amavisd-new. But I don't think that's an error or oversight, that's our
ignorance :) And don't want to be ignorant :) So I've asked the question :)
postgresql-server uses it..
--
Przemyslaw Nowaczyk <p_nowaczyk@o2.pl>
CS student @ Poznan University of Technology
http://www.student.put.poznan.pl/~przemyslaw.nowaczyk/
Hi!
Probably most programs that need non-trivial cleanup handle SIGTERM
appropriately.Kind regards,
Hannah.
Probably most of the programs does handle SIGTERM appropriately, but it
may be too little time for a program to clean itself before it receives
SIGKILL signal. For an example mysql. It needs to kill any connections to
it (and if any problem killing it, it should wait for some time and then
try again), sync data, remove socket (I don't know the exact order of
mysql shutdown task and I'm only guessing). And what if SIGKILL arrives
in the middle of the mysql shutdown tasks?Hannah Schroeter wrote:
Hi!
On Wed, Sep 19, 2007 at 02:48:54PM +0300, Tomas wrote:
Watching the thread about startup script I thought of a question about
shutdown script. Is it necessary to shutdown certain services when
machine goes down? Like for example mysql, dovecot, clamav, amavis or
openvpn. I've never saw anybody do that. Lots of people on their
manuals, tutorials or posts writes how to start mysql, but none of then
writes a shutdown script. So maybe it is not so necessary? (But then
again, mysql is a database engine, and databases should be handle with
care).Probably most programs that need non-trivial cleanup handle SIGTERM
appropriately.Kind regards,
Hannah.
| Amit K. Arora | [RFC] Heads up on sys_fallocate() |
| H. Peter Anvin | Re: [RFC 00/15] x86_64: Optimize percpu accesses |
| Nicolas Pitre | Re: [RFC patch 08/18] cnt32_to_63 should use smp_rmb() |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
git: | |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | [GIT]: Networking |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Natalie Protasevich | [BUG] New Kernel Bugs |
