1

I want to kill all google chrome process which is run via CRON.

*/5 * * * * export DISPLAY=:0 && google-chrome --app=http://localhost/runmysql.html 

so the process which has lower process id I want to keep, and greater than that I want to kill which run via CRON and which has higher process id then initial.

I know how to kill all process

sudo killall -9 chorme
0
1

First, get the PIDs of the processes:

pgrep google-chrome

To kill all the google-chrome processes with PIDs greater than say, 4500:

kill -9 $(pgrep google-chrome | awk '$1>4500')

Example output:

ron@ron:~$ pgrep sleep 
3956
4656
4978
4992
ron@ron:~$ kill -9 $(pgrep sleep | awk '$1>4500')
[2]   Killed                  sleep 1000
[3]-  Killed                  sleep 4500
[4]+  Killed                  sleep 6000
roronn@4736Z:~$ pgrep sleep
3956
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.