Operating System - HP-UX
1753779 Members
7352 Online
108799 Solutions
New Discussion юеВ

Re: default umask for cron

 
Luis Toro
Regular Advisor

default umask for cron

I will be changing the umask setting in /etc/profile to be more restrictive. In running some simple tests in cron, to test the impact of this change, I noticed that even though umask was set to 027 in /etc/profile, new file permissions were rw-r--r-- in running a "touch" command in roots cron. This is on an HPUX server.
Thanks
12 REPLIES 12
Patrick Wallek
Honored Contributor

Re: default umask for cron

Cron does NOT source any profiles, /etc/profile or ~/.profile.

If you want a specific umask in your cron scripts you need to set it manually in the scripts themselves.
Luis Toro
Regular Advisor

Re: default umask for cron

Thanks Patrick.
Perhaps the better question is: where is cron getting its umask?
Dennis Handly
Acclaimed Contributor

Re: default umask for cron

>Perhaps the better question is: where is cron getting its umask?

You should just set umask the way you want it in your scripts as Patrick said.

Otherwise cron is started from rc, which is started from inittab.
Kapil Jha
Honored Contributor

Re: default umask for cron

I think i got your question,
Patrick is absolutely right when he says cron does not refer any .profile file,you have to put in cron script.

Dennis
>Otherwise cron is started from rc, which is started from inittab

Lis question is if he is running touch from cron entry file has permission 644.
So from where this permission is coming.

I think its the default one 022 as said by Dennis.Cron start from rc.
When u change umask for root or someone from .profile it would be effective only for that login.
BR,
Kapil
I am in this small bowl, I wane see the real world......
Kapil Jha
Honored Contributor

Re: default umask for cron

Now m confused with your error , default mask should come from /etc/profile(global)
and I think cron should take default from this only.
Can you please check once again entries you have in /etc/profile.
BR,
Kapil
I am in this small bowl, I wane see the real world......
Dennis Handly
Acclaimed Contributor

Re: default umask for cron

>Kapil: Now I'm confused with your error

Why? You said exactly what umask was, 022. This is hardcoded in /sbin/rc.
And that matches with what Luis said touch did.

>default mask should come from /etc/profile

But it gets reset by rc(1m).

>I think cron should take default from this only.

No, cron gets it from rc.
Kapil Jha
Honored Contributor

Re: default umask for cron

So it moves like
rc > /etc/profile > HOME/.profile

if /etc/profile and HOME/.profile does not have any specified umask then default would come from rc.
Right...

Kapil
I am in this small bowl, I wane see the real world......
Dennis Handly
Acclaimed Contributor

Re: default umask for cron

>Kapil: So it moves like
>rc > /etc/profile > HOME/.profile

Why?

It moves like: maybe /etc/profile > HOME/.profile
rc > umask 022 > /sbin/rc.utils, rc.config
>> rc scripts

>if /etc/profile and HOME/.profile

Why would these be looked at after rc starts?
OldSchool
Honored Contributor

Re: default umask for cron

Kapil:
"if /etc/profile and HOME/.profile does not have any specified umask then default would come from rc.
Right..."

and cron *doesn't* login, so it doesn't use the profiles....which is why its set to the default....