I
I
Igor Petrov2011-12-22 13:10:21
PowerShell
Igor Petrov, 2011-12-22 13:10:21

Help with bash script

Friends, we need your help.
I urgently needed a solution, and only a phone was available from improvised means :-(
In general, closer to the point. It is necessary to write a script that terminates all processes in the system whose pid is less than the pid of the script itself, except for pid from 0 to 100.
P.S. Session

Answer the question

In order to leave comments, you need to log in

1 answer(s)
@
@sledopit, 2011-12-22
_

something like this:

 $ cat kill.sh 
#!/bin/bash

CUR_PID=$$
echo "CURRENT PID = " ${CUR_PID}

ps -eo pid | sed 1d | while read PID ; do [ $CUR_PID -gt $PID -a $PID -gt 100 ] && kill -15 $PID ; done 

surely can be optimized to death. that's it, in a hurry.
PS PID=0 does not happen.
zzy. You need to study not in the session, but before it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question