Answer the question
In order to leave comments, you need to log in
How to replace the name of all containers with their ip in a loop?
There are containers
CTID NPROC STATUS IP_ADDR HOSTNAME
101 19 running 127.0.0.2 test1
102 19 running 127.0.0.3 test2
vzctl set 101 --hostname "127.0.0.2" --save
Answer the question
In order to leave comments, you need to log in
For example, through a temporary file.
vzlist -H -o ctid | awk ' { print "vzctl set " $1 , " --hostname \"" $4 "\" --save" }' > /tmp/cmd
Check what happened in /tmp/cmd
If everything is fine, then execute it:
sh /tmp/cmd
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question