0

I have a super simple system crontab to run as a specific user. For a user that can login to a Gnome session it works fine. For another user that I use just for system tasks, it will not run.

This is a CentOS 7 box that shows systemctl status crond as running.

To debug the situation I have reduced the file /etc/cron.d/test to:

SHELL=/bin/bash

* * * * * etluser /bin/echo "-- trying" >> /tmp/auto_services.txt

With the user etluser nothing runs. The tmp file does not appear. There is no output in journalctl -xe, no /var/log/cron entry and no email to root.

$ getent group etluser
etluser:x:499:otheruser

$ getent passwd etluser
etluser:x:600:499::/home/etluser:/bin/bash

$ getent shadow
etluser:$6$mw...../:18429:0:90:7:::

Also /etc/cron.deny is empty and /etc/cron.allow is not present.

If I change the user in the cron.d file to my standard login user otheruser then the job runs fine.

SHELL=/bin/bash

* * * * * otheruser /bin/echo "-- trying" >> /tmp/auto_services.txt

/etc/pam.d/crond shows

account    include    system-auth
session    required   pam_loginuid.so
session    include    system-auth
auth       include    system-auth

Any idea what I'm missing?

0

It seems that the job won't run if the password of the user has expired. I wouldn't normally know this has happened as I just sudo -u etluser -i to work as that user, and that doesn't fail.

Resetting the password did the trick. Now I just need to set a dummy password and set the expiration time to a lifetime.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.