Killing a Stuck Process

Killing a Stuck Process

killProcess.rb

Applications are wonderful additions to operating systems. But occasionally they get stuck and begin to cause a self-inflicted Denial of Service attack on your system. Some processes are very stubborn and take extra effort to completely kill. This wicked little script will intuitively identify the stuck processes and automatically terminate them. How's that for avoiding additional manual work?

The Code

 #!/usr/bin/ruby
 max_time = 300
 ps_list = `ps h -eo cputime, pcpu, pid, user, cmd`

 list ...

Get Wicked Cool Ruby Scripts now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.