Shell – Default umask for cron jobs

cronshellumask

How to set default umask for cron jobs, please? (On RHEL 6.)

Jobs are started under non-interactive (obviously) no-login (?) shell. Not only I prefer dash over bash. But consider also bash called as /bin/sh. It seems, that both shells in non-interactive no-login invocation doesn't read any start-up file like /etc/profile.

Is the default umask hard-wired in shell or it is inherited from cron daemon?

Best Answer

On RHEL, PAM is used, so you could try using pam_umask

Try putting this in /etc/pam.d/crond

session optional pam_umask.so umask=0022

Naturally, this is untested, and may very well break assumptions made by various applications.

Related Question