Affichage des articles dont le libellé est awk. Afficher tous les articles
Affichage des articles dont le libellé est awk. Afficher tous les articles

jeudi 28 octobre 2021

kill processes from docker-compose "container_name"

Context : 

follwing a project-name change -> renaming the directory-name/docker-compose.yml the processes that were started by docker-compose were duplicated.

From the new project :

*  impossible to see them.

From docker ps : no process listed

From OS perspective ps aux : process present.


Test 1 : kill them all !

 Step 1 : identify them

ps aux | grep $(echo "$(grep container_name docker-compose.yml | grep -v '#' | awk '{printf("%s\\|", $2)}')grep")


Step 2 : kill -9 them all


ps aux | grep $(echo "$(grep container_name docker-compose.yml | grep -v '#' | awk '{printf("%s\\|", $2)}')grep") | awk '{print $2}' | xargs sudo kill -9


-> result : when restarting docker, they're back :-( 


Test 2 : stop docker + docker-compose start

apparently working, but I lost my container's content...


mercredi 11 février 2015

awk 'system()' vs xargs

Two different syntaxes for processing a command over a list of arg.

Let's take for example, the list of PID you want to kill(all the processes matching "toto") :

ps | grep toto | awk -F' ' '{print $2}' | xargs kill -9

is equivalent to

ps | grep toto | awk -F' ' '{system("kill -9 "$2}'

note that the space at the end of the string "kill -9 " is important since the $2 will be concatenated.