Skip to content

Instantly share code, notes, and snippets.

@nl5887
Last active December 26, 2017 11:07
Show Gist options
  • Select an option

  • Save nl5887/a05e5de2f92c980a0a36 to your computer and use it in GitHub Desktop.

Select an option

Save nl5887/a05e5de2f92c980a0a36 to your computer and use it in GitHub Desktop.
stop all lxc instances
#!/bin/bash
lxc-ls --frozen | while read line; do echo Unfreezing $line; lxc-unfreeze --name $line; done < /dev/stdin
lxc-ls --running | while read line; do echo Stopping $line; lxc-stop --name $line; done < /dev/stdin
lxc-ls --frozen|grep -v troje_base | while read line; do echo Stopping $line; lxc-unfreeze --name $line; done < /dev/stdin
lxc-ls --running|grep -v troje_base | while read line; do echo Stopping $line; lxc-stop --name $line; done < /dev/stdin
lxc-ls --stopped|grep -v troje_base | while read line; do echo Stopping $line; lxc-destroy --name $line; done < /dev/stdin
@skamoen
Copy link
Copy Markdown

skamoen commented Dec 26, 2017

The lxc-ls output format changed. Use lxc-ls -1 --frozen to make the while read line work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment