?
Solved

umask for cron jobs

Posted on 2004-11-10
6
Medium Priority
?
3,542 Views
Last Modified: 2008-02-01
Hi,

I am running a RedHat 2.1AS Linux box and I need the default umask to be 002. I set it in /etc/profile and /home/user/.bash_profile for each user; however, when jobs are run by cron as root, the umask doesn't seem to be in effect. Is there any way to make the umask the correct value permanently without actually adding the commands into the scripts run by cron?

Thanks
0
Comment
Question by:LPTech
  • 3
  • 2
6 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 1000 total points
ID: 12545254
Basically no, cron doesn't call the profile, so either add it to the script or do something like
10 4 * * * umask 002 ; /path/to/script
0
 

Author Comment

by:LPTech
ID: 12545329
Great, thanks~!
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 12545393
Hi,

   What's your cron script? I assume that is a sh or bash script.
How about /etc/bashrc in addition to /etc/profile and /home/user/.bash_profile?

Wesly
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:LPTech
ID: 12545534
It's actually a perl script...
0
 
LVL 18

Expert Comment

by:liddler
ID: 12545599
You could call a system command from perl -
system (umask 002);
0
 

Author Comment

by:LPTech
ID: 12545745
Yeah, I was hoping to not have to make a code change to the script due to source control\testing problems... Adding the umask 002 to the crontab works perfectly. =P
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question