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)
systemctlis 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,/sbinare all symlinks to/usr/bin.
systemctl suspenddoesn'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/erroror something to capture any errors you might be getting. Finally, tell us which user is running this crontab.