每当我输入 killall java -9 时,所有 java 进程都会被终止,即使我更改了进程名称。那么有没有办法保护 java 进程不被“killall java -9”终止
答案1
简单的解决办法是使用不同的用户运行该进程. 那么,您(作为您当前的用户)将无权终止所有名为 的进程java
,除非您是root
。
我,,deltik
没有正在java
运行的进程。 top
显示:
Processes: 80 total, 3 running, 1 stuck, 76 sleeping, 435 threads 21:22:54
Load Avg: 1.66, 1.47, 1.40 CPU usage: 33.49% user, 2.65% sys, 63.85% idle
SharedLibs: 7552K resident, 4480K data, 0B linkedit.
MemRegions: 15059 total, 1858M resident, 32M private, 372M shared.
PhysMem: 298M wired, 2332M active, 1289M inactive, 3918M used, 176M free.
VM: 164G vsize, 1041M framework vsize, 490174(73) pageins, 7225(0) pageouts.
Networks: packets: 1543452/932M in, 1286039/414M out.
Disks: 103231/3309M read, 218839/2343M written.
PID COMMAND %CPU TIME #TH #WQ USER
1159 java 108 02:28:38 45/2 1 somebody
1769 top 4.0 00:10.32 1/1 0 root
765 bash 0.0 00:00.00 1 0 deltik
...
这是我尝试时的输出killall -9 java
:
Deltik-iMac:~ deltik$ killall -9 java
No matching processes belonging to you were found
我无法终止java
拥有的进程somebody
。