列出升级后使用已删除库的可重新启动程序或服务

restartable的Python项目详细描述


可重新启动

使用最近升级删除的文件列出正在运行的进程

Build Status

升级包时,包管理器不会重新启动依赖于某些已更新库的服务或程序,原因显而易见对于仍在使用的过时库,这会带来安全隐患。

opensuse有一个很酷的zypper ps命令,可以使用删除的文件检查程序和服务。 它也可以在其他发行版中作为zypp-CheckAccessDeletedlibzypp包中获得。 这些命令解析lsof输出并检查/proc/<pid>/cgroup以提取服务名称。

下面是一个python版本,它检查/proc/<pid>/maps,从/proc/<pid>中的其他文件中提取信息。

不需要依赖性。

摘自zypper手册:

After each upgrade or removal of packages, there may be running processes on the system which continue to use meanwhile deleted files. zypper ps lists all processes using deleted files, together with the corresponding files, and a service name hint, in case it’s a known service. This gives a hint which services may need to be restarted after an update. Usually programs which continue to use deleted shared libraries. The list contains the following information:

PIDID of the process
PPIDID of the parent process
UIDID of the user running the process
LoginLogin name of the user running the process
CommandCommand used to execute the process
ServiceService name, if command is associated with a system service
FilesThe list of the deleted files

安装

sudo pip3 install restartable

用法

sudo restartable [OPTIONS]

List running processes using files deleted by recent upgrades

Options:
    -P, --proc PROC_DIRECTORY
	Specify /proc directory
    -s, --short
	Create a short table not showing the deleted files. Given twice,
	show only processes which are associated with a system service.
	Given three times, list the associated system service names only.
    -v, --verbose
        Show the complete command line

注释

  • 已验证可在Python3.4+上运行
  • 必须以根用户身份运行它才能查看所需的信息
  • 输出与zypper ps不同,它易于解析

缺陷/限制

  • 只有在Systemd启动时才能提取服务名

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java将Map<String,String>传递给需要Map<String,Object>   java在循环中使用字符串而不是StringBuilder是否会造成内存损失?   jnlp如何更新java控制台JRE?   java更改、修改和重新打包CXFAPI源文件   JavaFXJava应用程序在Fedora上运行一段时间后关闭   使用来自不同类的方法的java   java如何通过ant脚本在linux中使用subst?   java在使用camunda modeler进行base64编码/解码时出错   获取java。netbeans、weblogic和fastswap设置为true时的lang.NoSuchMethodError   java如何提高FinalizerThread在GC中收集对象的优先级   java检测具有相同根的单词   netbeans crud应用程序中的java错误