Hi,
I have a backup-script for my Linux Mint machine. I wanted to block shutdown, sleep or logout commands until the script is running.
systemd-inhibit --what=shutdown:sleep:idle:handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch tar -czf /media/fabian/hdd_extern/backup_fabian/home_$datum.tar.gz /home/fabian/*
So far so good. It works when i try to shutdown the machine via commandline, but when I press the shutdown button in the cinnamon gui the user logs off an the process gets terminated.
Has anyone an idea how to fix this? Thanks for your answers
systemd-inhibit doesnt work with cinnamon gui shutdown button
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
systemd-inhibit doesnt work with cinnamon gui shutdown button
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: systemd-inhibit doesnt work with cinnamon gui shutdown button
Use
Send the HUP or INT signal during the 9-second countdown (with kill or ^C) to see it work.
nohup
before your command; it keeps the process alive, if the HUP signal is sent to it. Might help. You can also tell your script what to do if it detects the HUP (or other) signal, using the trap
builtin -- see help trap
. Example usage of the trap
command:Code: Select all
#!/bin/bash
trap 'printf "\nSignal HUP (1) or INT (2) detected.\n"' HUP INT
for INT in {9..1}; {
printf "\rSleeping for %d second(s)..." "$INT"
/bin/sleep 1s
}
printf "\nThe script executed without being hung up.\n"
I'm also Terminalforlife on GitHub.