# Ubuntu – Can I prevent the time consuming backup command from being interrupted by system suspension due to inactivity for a period

backuppower-managementsuspend

I am using XFCE power manager. Under System tab, for System Power Saving part, I choose System Sleep Mode to be: suspend when inactive for 1hr when Plugged in. The maximum inactive time length is 6 hours.

If I am running a command to back up my home to an external drive, such as

sudo rsync -a /home/tim  /media/tim/externaldrive/  2>rsync-errors


which can take more than 10 hours, and I leave my laptop alone and go to sleep, will my Ubuntu be suspended one hour after I leave my laptop, and therefore interrupt the backup command?

If yes, how can I prevent my backup command from being interrupted, without changing System Sleep Mode?

Thanks.

• 1) systemd's inhibit

Using systemd's inhibit for a single process can be accomplished by running

sudo systemd-inhibit --what=idle:sleep:shutdown:handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch --mode=block rsync -a /home/tim  /media/tim/externaldrive/  2>rsync-errors


systemd-inhibit requires elevated privileges. The invoked command was run as root on my system. For additional options see either Systemd-inhibit or run man systemd-inhibit