You are not logged in.

#1 2013-03-08 08:51:17

7x1x
Member
From: Japan
Registered: 2009-10-16
Posts: 34

Cron lacks permissions to shutdown computer

So I'm attempting to shutdown my pc with cronie, however cron lacks the permissions to shutdown the machine. Cron calls "/usr/bin/systemctl poweroff" which broadcasts  "The system is going down for power-off NOW!" and nothing happens. It works fine invoked from the terminal or root's crontab. I suspect it has something to do with PAM permissions.

Any help would be greatly appreciated.

crontab -e

18 19 * * * /usr/bin/systemctl poweroff

journalctl -u cronie

-- Logs begin at Fri 2013-03-08 19:14:22 NZDT, end at Fri 2013-03-08 19:18:19 NZDT. --
Mar 08 19:14:23 archpc crond[298]: (CRON) INFO (Syslog will be used instead of sendmail.)
Mar 08 19:14:23 archpc crond[298]: (CRON) INFO (running with inotify support)
Mar 08 19:18:01 archpc crond[298]: (user) RELOAD (/var/spool/cron/user)
Mar 08 19:18:01 archpc crond[899]: pam_unix(crond:session): session opened for user user by (uid=0)
Mar 08 19:18:01 archpc CROND[900]: (user) CMD (/usr/bin/systemctl poweroff)
Mar 08 19:18:01 archpc CROND[899]: (user) CMDOUT (Failed to issue method call: Access denied)
Mar 08 19:18:01 archpc CROND[899]: (user) CMDOUT (Failed to issue method call: Access denied)
Mar 08 19:18:01 archpc CROND[899]: pam_unix(crond:session): session closed for user user

/etc/pam.d/crond

auth      required    pam_unix.so
auth      required    pam_env.so

account   required    pam_access.so
account   required    pam_unix.so
account   required    pam_time.so

session    required   pam_loginuid.so
session   required    pam_limits.so
session   required    pam_unix.so

Offline

#2 2013-03-15 09:25:11

jv2112
Member
Registered: 2011-07-23
Posts: 160

Re: Cron lacks permissions to shutdown computer

Try & do under root.

sudo bash

crontab -e

Life is pleasant. Death is peaceful. It's the transition that's troublesome. Isaac Asimov - / -

Offline

#3 2013-03-18 07:27:24

7x1x
Member
From: Japan
Registered: 2009-10-16
Posts: 34

Re: Cron lacks permissions to shutdown computer

Thanks for the reply. It works as you suggested. However, my user has permission to poweroff the machine so I shouldn't need to use root crontab.

Offline

#4 2013-03-18 12:45:37

Antoine
Member
From: Picton Ontario
Registered: 2012-10-11
Posts: 90

Re: Cron lacks permissions to shutdown computer

7x1x wrote:

Thanks for the reply. It works as you suggested. However, my user has permission to poweroff the machine so I shouldn't need to use root crontab.

But cron knows nothing about your user. I use something like:

SHELL=/bin/zsh
15        0-23/4  *       *       *       . /home/antoine/.zprofile && imac_bak

which brings in my environment before it executes the next file.

Also, at the risk of sounding stupid, those systemctl commands have to be run in the same "session" that the user is logged in on, I believe; I don't know if cron doesn't log in on a different session.

Offline

Board footer

Powered by FluxBB