列出升级后使用已删除库的可重新启动程序或服务
restartable的Python项目详细描述
可重新启动
使用最近升级删除的文件列出正在运行的进程
升级包时,包管理器不会重新启动依赖于某些已更新库的服务或程序,原因显而易见对于仍在使用的过时库,这会带来安全隐患。
opensuse有一个很酷的zypper ps
命令,可以使用删除的文件检查程序和服务。
它也可以在其他发行版中作为zypp-CheckAccessDeleted
从libzypp
包中获得。
这些命令解析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:
PID | ID of the process |
PPID | ID of the parent process |
UID | ID of the user running the process |
Login | Login name of the user running the process |
Command | Command used to execute the process |
Service | Service name, if command is associated with a system service |
Files | The 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启动时才能提取服务名