I have this cronjob set :
* * * * * /usr/bin/systemctl suspend
And it is not working. But I can run it in a shell and it works. I don't understand what could be not working.
EDIT
Redirecting error output to /tmp/error
gives this :
Failed to issue method call: Access denied
Failed to issue method call: Access denied
My question is then : Are cronjobs run as a special user (cron
for example), which would explain that my user can run the command, but not cron
itself?
Additional explanation :
This is a minimal example to show a problem I have in a script (that makes more sense than the single command provided here)
systemctl
is part ofsystemd
. I think reboot, shutdown, suspend are working with a non-root user withsystemd
. Anyway, it is working on my system.Finally, I use Arch Linux and
/bin
,/usr/sbin
,/sbin
are all symlinks to/usr/bin
.
systemctl
is in/usr/bin
and it acceptssuspend
like that? What *nix are you using? – terdon Sep 16 '13 at 02:02systemctl suspend
doesn't work on Debian or RedHat distros) and so is explaining that you don't actually want to do what you're showing :). Also, try adding2> /tmp/error
or something to capture any errors you might be getting. Finally, tell us which user is running this crontab. – terdon Sep 16 '13 at 02:11