How to safely abort apt-get install? 安全终止apt-get!

方案一:


When I encounter a failure with apt-get, I do the following (as root, i.e.sudobefore all commands):

  1. Kill the process named apt-get:

    killall -9 apt-get
  2. Reconfigure dpkg:

    dpkg --configure -a
  3. Update apt-get:

    apt-get update
  4. Update packages, including those improperly installed:

    apt-get upgrade

This I learned from somewhere, but unfortunately I cannot remember exactly where.


方案二:

sudo dpkg -r <package name>

In my case I had problems with Java 8 on Ubuntu 12.04, so...

sudo dpkg -r oracle-java8-installer


最终通过方案2搞定!


最佳答案(没什么作用):

Killing processes

Generally speaking for killing a process, there's no safer way to kill a process than with a regular kill (SIGTERM). In case it's an interactive process it usually allows you to stop it even safer by sending a SIGINT signal, usually sent by pressingCtrl+C. This signal is being trapped by the process itself can listen to it - and usually stop gracefully. (thanks Eliah)

DPKG database

Regarding the package management is a sort of special case. The DPKG database that the APT commands use under water can always detect whether an operation hasn't finished. Every package has an actual state which is marked in as well as a current state, e.g. unpacked, configured, etc. By killing the APT frontend, the database will be in a broken, but in known state. The lock files will only be released once it's all back in a clean state - you should get this fixed until it allows new operations.

The way to fix is just firing a process to get all packages in the configured state. Practically speaking, if you've interrupted anapt-getoperation, you can just finish it later using

sudo dpkg --configure -a

It knows how to recover from the broken state to an all-configured state and in that sense just continue from where it was interrupted. The lock files are left there until you finished that, and that's for a reason - to prevent new operations with the DPKG database in an unclean state.

About SIGKILL (9)

Sending a SIGKILL (decimal representation 9) is very unsafe. This signal is not catched by the process, but the whole process will be cleaned up by the operating system (kernel) whether the process likes it or not. The state of the files on the file system can be left in a corrupt state. Never send these signals unless it's not listening to other more graceful signals anymore.


转载于:https://my.oschina.net/uniquejava/blog/225838

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值