[systemd-devel] From command-line 'systemctl suspend' works' from cron it does not

Cecil Westerhof cldwesterhof at gmail.com
Sat Apr 2 00:03:16 UTC 2016


2016-04-01 21:34 GMT+02:00 Lennart Poettering <lennart at poettering.net>:

> On Mon, 21.03.16 09:21, Cecil Westerhof (cldwesterhof at gmail.com) wrote:
>
> > When executing
> >     systemctl suspend || echo "Error code: ${?}"
> > from the command-line it outputs
> >     Error code: 1
> > and it puts my machine in suspend.
> >
> > When putting it in cron it gives the following errors:
> >     Failed to execute operation: Access denied
> >     Failed to start suspend.target: Access denied
> > and gives the output:
> >     Error code: 4
> >
> > What is happening here? Is it possible to run 'systemctl suspend' from
> > cron, or is there a reason why this is not possible?
>
> if you run "systemctl suspend" as unprivileged user, PolicyKit is
> queried whether your user shall be allowed the opreatoin. The default
> policy for PolicyKit we install says that users on local consoles may
> suspend the system. However, a cron user is not on a local console,
> hence doesn't get this privilege.
>

​OK, thanks. I solved it by using sudo.


-- 
Cecil Westerhof
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20160402/cfa6595b/attachment.html>


More information about the systemd-devel mailing list