2
1
What's the correct way to shutdown system while apt-get is still running? apt-get complains about unclean shutdown when I just shutdown computer.
2
1
What's the correct way to shutdown system while apt-get is still running? apt-get complains about unclean shutdown when I just shutdown computer.
5
As an elaboration on Piskvor's advice ("don't"), you could issue this command at the shell prompt:
sleep 10m ; shutdown -h now
The above assumes you're running as superuser.
The idea is to let apt-get finish before shutting down without your having to sit there waiting for it to end. You could write a more elegant script that, e.g., uses ps and grep to detect whether apt-get has completed, but I don't have access to a Linux box here at work to test such a script on.
Good not-so-technical idea (I would +1 it, but I don't have reputation to do that, so I can only say thanks), but I want something like "instant clean shutdown" thing. – None – 2011-09-09T14:12:43.287
2
Close apt-get first? Perhaps using an interrupt signal (^C if in foreground, otherwise kill
)
Update:
You can get a list of signals with kill -l
$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE
9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
13) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD
18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN
22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO
30) SIGPWR 31) SIGSYS 32) SIGRTMIN 33) SIGRTMIN+1
34) SIGRTMIN+2 35) SIGRTMIN+3 36) SIGRTMIN+4 37) SIGRTMIN+5
38) SIGRTMIN+6 39) SIGRTMIN+7 40) SIGRTMIN+8 41) SIGRTMIN+9
42) SIGRTMIN+10 43) SIGRTMIN+11 44) SIGRTMIN+12 45) SIGRTMIN+13
46) SIGRTMIN+14 47) SIGRTMIN+15 48) SIGRTMAX-15 49) SIGRTMAX-14
50) SIGRTMAX-13 51) SIGRTMAX-12 52) SIGRTMAX-11 53) SIGRTMAX-10
54) SIGRTMAX-9 55) SIGRTMAX-8 56) SIGRTMAX-7 57) SIGRTMAX-6
58) SIGRTMAX-5 59) SIGRTMAX-4 60) SIGRTMAX-3 61) SIGRTMAX-2
62) SIGRTMAX-1 63) SIGRTMAX
Before trying 9 (SIGKILL), the nuclear option, you can try gentler signals such as HUP, INT, QUIT, or maybe USR1, USR2 or ABRT. Really the program docs for apt-get ought to say if it handles any of these signals differently. As it doesn't I don't hold out a lot of hope. Some bug reports mentioned that INT should work.
1I think that won't work, init sends kill signal to all processes when shutting down and next time when running apt-get it isn't so happy about that, but I'll try it. – None – 2011-09-09T13:19:36.260
@Matej: you can kill -15
which sends the TERM
(inate) signal instead of the KILL
signal. Perhaps during shutdown, the time between TERM
and KILL
is not long enough for apt-get
to exit cleanly? – Piskvor left the building – 2011-09-09T13:24:57.280
@Piskvor: OK, I'll try both kill and kill -15 and see what is better for apt-get. – None – 2011-09-09T13:32:15.430
4Uh, don't shutdown if you're in the middle of installing something? Or is that not an option? (How? e.g. the user who installs is not you?) – Piskvor left the building – 2011-09-09T12:58:40.583
@Piskvor: Just want to know if this is possible (maybe it will be useful one time). – None – 2011-09-09T13:17:19.150