Kill program by lowest PID
Приветствую.
Ребята, помогите разобраться. Есть таск. Напишу оригинал:
Show the UNIX command to check if program is running or not and kill it immediately.
The program could be started by you or by another user, so only yours should be killed.
Plus, if it was started twice or more, so the copy with lowest PID should be killed only.
пока сделал так:
kill -9 programname | grep username; for pid in 'ps aux | grep programname | awk {'print $2'}'; do kill $pid; done
это навскидку, проверить не могу. Надо всё в одну строчку. Не знаю, как применить проверку PIDа.
у кого какие предложения на этот счет?