The problem

My laptop is configured to go to sleep after two minutes of being idle.

But it also suspends while a backup to an external disk is running :(

The solution

The solution is to tell your system that something important is running and that it should not go to sleep/suspend or to shut down.

With systemd you can use the command „systemd-inhibit“. Read the man page… (man systemd-inhibit).

Instead of starting your backup script directly you start it with:

systemd-inhibit \
--what="shutdown:sleep:idle:handle-lid-switch" \
--who="My backup script" \
--why="Finish the backup." \

Please note that this is a single line but I split it for better reading. Copy and paste all 5 lines.

You may also modify your backup script to run the backup command with systemd-inhibit.

Optional: Create an alias

I created the following alias in the global shell rc to be able to use systemd-inhibit for my backup or other important stuff without the need to remember the options:

alias nosuspend='systemd-inhibit --what="shutdown:sleep:idle:handle-lid-switch"'


user@host $ nosuspend /path/to/your/

List inhibitions

To get a list of inhibitions on your system use:

systemd-inhibit --list

Almost perfect…

…the systemd-inhibit does only work if a command is running as root, while KDE/Plasma is running as a unprivileged user. But thats sufficient for what I want because my backup script does need root privileges. So I don’t need to „fix“ that issue for my case. Maybe later…

So now KDE/Plasma asks for a legitimation to go to sleep/standby and thats it.

Read the docs :)

See if you need more information.