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

Cecil Westerhof cldwesterhof at gmail.com
Thu Mar 24 07:14:03 UTC 2016


2016-03-23 8:11 GMT+01:00 Cecil Westerhof <cldwesterhof at gmail.com>:

> Have you tried running from a root
>
>> crontab?
>>
>
> ​Just tried it and that works. One important difference: it returns an
> error code of 0 instead of 1.
> So probably I need to setup a systemd session. How am I going to do that?
>

​I understood that not on all systems a normal user has the ability to use
suspend and hibernate. Which makes sense. So I now use sudo in the script
and added to '/etc/sudoers':
    cecil ALL = (root) NOPASSWD: /bin/systemctl suspend
    cecil ALL = (root) NOPASSWD: /bin/systemctl hibernate

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


More information about the systemd-devel mailing list