当我启动“reboot”或“poweroff”时,systemd正在终止所有进程,但是我需要在停止其他服务之前等待一个特定的应用程序完成。
其实,我想要Virtualbox虚拟机清理关机/ savestate。 使用此服务文件手动执行操作没有问题,但在closures期间 – 进程被终止。 我如何控制它?
我读过文档,但没有find明确的解决scheme,这种依赖。
[Unit] Description=virtualbox vm1 vm control service After=vboxweb-service.service Before=shutdown.target [Service] Type=oneshot ExecStart=/usr/bin/VBoxManage startvm vm1 -type vrdp ExecStop=/usr/bin/VBoxManage controlvm vm1 savestate RemainAfterExit=true
解决了。
[Unit] Description=virtualbox windows vm control service After=vboxweb-service.service Before=shutdown.target reboot.target halt.target [Service] Type=oneshot ExecStart=/usr/bin/VBoxManage startvm windows -type vrdp ExecStop=/usr/bin/VBoxManage controlvm windows savestate RemainAfterExit=true KillMode=none [Install] WantedBy=multi-user.target