基本上,我想阻止一些系统进程运行。如果我强制退出它们,它们只会重新启动。如何防止它们启动/重新启动。
在你说我不应该搞乱系统进程之前:我完全理解可能的后果。
这取决于进程是如何启动和重新启动的。大多数系统进程由launchd处理;如果这是您想要摆脱的进程的情况,您需要找到控制它的启动项(它将是 /System/Library/LaunchDaemons 或 /Library/LaunchDaemons 中的 .plist 文件之一)和禁用它sudo launchctl unload /path/to/launchd/item.plist。如果您想让它永久化(即即使重新启动也保持禁用状态),请添加 -w 标志:sudo launchctl unload -w /path/to/launchd/item.plist。以下是查找和关闭 krb5kdc 进程的示例:
# First, find the pid of the running process:
$ ps -axwww | grep [k]rb5kdc
3143 ?? 0:33.38 /usr/sbin/krb5kdc -n
# Now find label of the the launchd item controlling it
$ sudo launchctl list | grep 3143
3143 - edu.mit.Kerberos.krb5kdc
# Now find the .plist file that defines that item label:
$ grep -l edu.mit.Kerberos.krb5kdc /Library/LaunchDaemons/* /System/Library/LaunchDaemons/*
/System/Library/LaunchDaemons/edu.mit.Kerberos.krb5kdc.plist
# Finally, disable the launchd item (permanently):
$ sudo launchctl unload -w /System/Library/LaunchDaemons/edu.mit.Kerberos.krb5kdc.plist
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9738 次 |
| 最近记录: |