Ubuntu – Prevent shutdown when rsnapshot is running

kdersnapshotshutdown

Since shutdowns during rsnapshot operation will lead to inconsistent/partial backups, I wonder how to delay the system shutdown while rsnapshot is active.

The task is complicated by the fact that I need a solution which is compatible with non-expert users i.e. I need to tell reliably to the user that he needs to wait until the process is finished and not to do a hard reset. Once this is the case shutdown should continue.

A possible solution could be to replace the action of the window managers (mostly KDE) shutdown/restart/hibernate buttons by a script which first checks if rsync is active and shows a message if this is the case. But I do not know if this is possible in KDE.

Best Answer

  • Try making a script to enable and disable shutdown then move the executable elsewhere then in its place put a script that:

    1. Disables shutdown
    2. Runs the program
    3. Enables shutdown

    See How to disable shutdown/reboot/suspend/hibernate?.