OK, had another look at this, and found that the following works.The check for shutdown.target must be after others, b/c it is active along with reboot.target and poweroff.target.
Code:
if [[ "$(systemctl list-jobs | grep reboot.target)" =~ "reboot.target" ]]then echo "System is rebooting"elif [[ "$(systemctl list-jobs | grep poweroff.target)" =~ "poweroff.target" ]]then echo "System is powering off"elif [[ "$(systemctl list-jobs | grep shutdown.target)" =~ "shutdown.target" ]]then echo "System is shutting down"fi
Statistics: Posted by bls — Wed Feb 07, 2024 1:27 am