Killing Processes Command
I know how to kill processes. I want to write a script
that will kill all the processes for a particular user excluding the virtual
terminal that he/she is currently using.
For example, I have user admin running a process called
rtsvis and they loose connection to the server. The process continues to
run. when they back in, they get assigned a new tty and start a new process
of rtsvis. I want to kill the old process without killing the one they
are currently running on the new tty.
As root:
# su - username -c 'kill -9 -1'
How to kill a user on a shell
How you would kill a user on a remote shell, I know
you can list them by doing who, but I have no clue how to kill a user.
Do `who -u` to get a list of the current logins. `who
-uH` if you want colnumn headers.
Then use the kill command followed by the Process ID
(PID) ex. `kill 1234`
If that doesn't kill it (because its hung or thinking
really really hard) you can do `kill -9 1234` where 1234 is the PID and
it will kill it imidiatly...
To kill off all of a users processes at once:
# su - username -c 'kill -9 -1'
Kill is Not Working Within awk
I need to run this script to protect the user1 from
more than 30% cpu usage. But kill is not working within awk.
What should I do?
#!/bin/bash
ps -fuU user1 >> psFile
awk '{ if( $3 > "30")
kill -9 $2 }' psFile
rm psFile
Calling an external command requires to use the system
command such as this:
system("kill -9 $2")
Quick Links:
Have a Linux Problem
Linux Forum
- Do you have a Linux Question?
Frequently Used Options
See also common Linux
Commands
Linux Books
Linux Certification,
System Administration, Programming, Networking Books
Hints and Tips on: Linux
System Administration
(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
All product names are trademarks of their respective
companies.
The site www.gotothings.com is in no way affiliated with
or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.
|