[systemd-devel] machinectl poweroff: wait until shutdown is done
Silvio Knizek
killermoehre at gmx.net
Mon Aug 5 15:41:27 UTC 2024
Am Montag, dem 05.08.2024 um 15:27 +0000 schrieb Joel GUITTET:
> Hello
> Is there a way when using "machinectl poweroff <name>" to wait until the container is effectively totally stopped ? So that the following command after machinectl poweroff can be executed safely (in my case un-mounting the rootfs, cleaning iptables rules etc etc).
> Thanks
> Joel
Hi Joel,
you can busy-loop here, if you don't define your dependencies via other
units. Something like
```bash
$MY_MACHINE='some_name'
machinectl poweroff "$MY_MACHINE"
while [[ "$(machinectl --property state --value show "$MY_MACHINE)" == "running" ]]; do
sleep 1
done
umount "${MY_MACHINE}_rootfs"
remove_iptables
etc
```
BR
Silvio
More information about the systemd-devel
mailing list