On 22/03/2021 11:07, Gordon Messmer wrote:
I'd like to inhibit suspend while backups run on my laptop.  I'm scheduling those backups 
with a systemd timer[1] and service[2]. I've read that the default polkit policy only 
permits inhibiting suspend from within a login session, so I've also tried to add rules 
to allow the root user to inhibit suspend[3].  However, with all of those in place, I 
still get errors that I think indicate that the "systemd-inhibit" command is 
failing[4].

I'm running this on Fedora 33.  Has anyone successfully used systemd-inhibit from a systemd unit?

I have not used, or even tried to use, systemd-inhibit.

But, when testing things I like to use examples which use simple system 
commands.  To verify that things
work as I think they should in various ways before trying my commands/scripts.

FWIW, I ssh'ed into a system and ran....

sudo /usr/bin/systemd-inhibit sleep 30

In another terminal, systemd-inhibit --list showed

sleep 30       0   root 2634 systemd-inhibit shutdown:sleep:idle

I then created a crontab for root of

00,10,20,30,40,50 * * * * /usr/bin/systemd-inhibit sleep 60

and at the appropriate minute in time systemd-inhibit --list showed

sleep 60       0   root 2681 systemd-inhibit shutdown:sleep:idle

The crontab, in particular, isn't a login session.  Note: --mode=block is the 
default according to the man page.

So, does your backup process work when called from crontab entry?

--
People who believe they don't make mistakes have already made one.

_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to