Whenever I type killall java -9 ,all java process is killed, even if i change the process name. So Is there an way to protect the java process being killed by 'killall java -9'
2Making a program that cannot be terminated from command prompt seems kind of...dangerous– JeffreyAug 29, 2012 at 1:33
1-9 is SIGTERM, which I believe there is no way to ignore that. And, it is the PROCESS being killed instead of THREAD– Adrian ShumAug 29, 2012 at 1:34
@Jeffrey that's what I'm thinking too :/– PicklishDoorknobAug 29, 2012 at 1:34
1You could run another (non-Java) process to restart your Java process when it unexpectedly closes.– EthanBAug 29, 2012 at 1:45
I think that the best answer is "just don't do it". (Like you wouldn't run "rm -rf" in the root directory!)– Stephen CAug 29, 2012 at 1:49
The simple solution is to run the process with a different user. Then, you (as your current user) would not have permission to kill all processes called
java, unless you were
deltik, do not have a
java process running.
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 ...
So this is my output when I try
killall -9 java:
Deltik-iMac:~ deltik$ killall -9 java No matching processes belonging to you were found
I cannot kill a
java process owned by
1Nice,+1. @jilen you could also use kill instead of killall to kill only the specific processes that need to go.– terdonAug 29, 2012 at 2:42
@terdon there is another script that use killall, I think I should better not change it– jilenAug 29, 2012 at 4:08
By run java as another user , I cannot access the home folder of the user.– jilenAug 29, 2012 at 4:09
You would presumably know the password of that user, so you could
su somebody.– DeltikAug 29, 2012 at 13:05