Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Seemingly Simple Cron Question: Any Ideas?, Cron and shell script umask settings.
larj
post Aug 8 2003, 11:06 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 1
Joined: 8-August 03
Member No.: 1,228



Hi all,

Is there a way to specify default umask settings for shell scripts run from a user's crontab?

Every time a script creates a file or directory, it's perms are rw-r--r--, despite my attempts to change to 'umask 002' (set in the user's .bashrc and /etc/profile).

Any ideas how I might get all cron scripts run by a single user to create files with perms of rw-rw----?
Go to the top of the page
 
+Quote Post
hughesjr
post Aug 8 2003, 03:26 PM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



How umask works....

If you type the command umask at the command prompt for the user (prior to any changes), it will probably say 0022 ... forget about the first 0 ... and the last 3 digits would subtract from 666 permissions (rw-rw-rw-) and make them 644(rw-r--r--) for file creation ... if you use umask 0006, it should change 666 to 660(rw-rw----) when creating files.

(umask can have 4 characters instead of 3 ... everyone forgets the first 0 and some systems will make a 002 be 0020 instead of 0002 ... and in most versions of *nix 3 digits will still work).
--------------------------------------
Here is how you can test umask .... set your umask with the command:

umask 0006

Then go to a directory you can write in ... I would just pick my home directory ...

Then issue the command:

touch file_permissions

Check the permissions with the command:

ls -al | grep permissions

Should be permissions of 660 (rw-rw----)

Then make a directory with the command:

mkdir dir_permissions

Then look at both the file and the directory:
ls -al | grep permissions

The directory will have 771 (rwxrwx--x) permissions .... for some reason an x is always added
-----------------------------------------------
Then just put either umask 0006 in either the user's .bashrc (or .bash_profile) ... or you can put umask 0006 in the script you are running.


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 23rd October 2017 - 05:34 PM