ashsysad
asked on
Creating file with 660 permission
I have a script that will log all its output to a new logfile that it is created with that day's timestamp. The content of these logfiles contains some confidential information. So I want these log files to be created with permission 660, so that only 'root' user can read it. I'm aware that it can be done by changing the 'umask' value but I don't want the change to affect globally. I just want for one particular folder where the logfiles will be created using script. Is that possible to do ? I had this question 4 years before when I got into similar situation but I couldn't succeed to get a solution.
[root@sysllm01 ]# ls -l
total 168
-rw-r--r-- 1 root root 4966 Mar 14 23:42 3-14-2011_orallm11.log
-rw-r--r-- 1 root root 4984 Mar 15 19:38 3-15-2011_orallm11.log
-rw-r--r-- 1 root root 4960 Mar 16 19:20 3-16-2011_orallm11.log
-rw-r--r-- 1 root root 4984 Mar 17 19:44 3-17-2011_orallm11.log
-rw-r--r-- 1 root root 4977 Mar 18 19:27 3-18-2011_orallm11.log
-rw-r--r-- 1 root root 4982 Mar 19 19:31 3-19-2011_orallm11.log
-rw-r--r-- 1 root root 4973 Mar 20 22:48 3-20-2011_orallm11.log
-rw-r--r-- 1 root root 4977 Mar 21 19:40 3-21-2011_orallm11.log
-rw-r--r-- 1 root root 4983 Mar 22 19:27 3-22-2011_orallm11.log
-rw-r--r-- 1 root root 4984 Mar 23 19:44 3-23-2011_orallm11.log
-rw-r--r-- 1 root root 4984 Mar 24 19:45 3-24-2011_orallm11.log
-rw-r--r-- 1 root root 4574 Mar 25 19:41 3-25-2011_orallm11.log
-rw-r--r-- 1 root root 1359 Mar 26 20:14 3-26-2011_orallm11.log
-rw-r--r-- 1 root root 4586 Mar 28 20:13 3-28-2011_orallm11.log
-rw-r--r-- 1 root root 5038 Mar 29 19:40 3-29-2011_orallm11.log
[root@sysllm01 ]# ls -l
total 168
-rw-r--r-- 1 root root 4966 Mar 14 23:42 3-14-2011_orallm11.log
-rw-r--r-- 1 root root 4984 Mar 15 19:38 3-15-2011_orallm11.log
-rw-r--r-- 1 root root 4960 Mar 16 19:20 3-16-2011_orallm11.log
-rw-r--r-- 1 root root 4984 Mar 17 19:44 3-17-2011_orallm11.log
-rw-r--r-- 1 root root 4977 Mar 18 19:27 3-18-2011_orallm11.log
-rw-r--r-- 1 root root 4982 Mar 19 19:31 3-19-2011_orallm11.log
-rw-r--r-- 1 root root 4973 Mar 20 22:48 3-20-2011_orallm11.log
-rw-r--r-- 1 root root 4977 Mar 21 19:40 3-21-2011_orallm11.log
-rw-r--r-- 1 root root 4983 Mar 22 19:27 3-22-2011_orallm11.log
-rw-r--r-- 1 root root 4984 Mar 23 19:44 3-23-2011_orallm11.log
-rw-r--r-- 1 root root 4984 Mar 24 19:45 3-24-2011_orallm11.log
-rw-r--r-- 1 root root 4574 Mar 25 19:41 3-25-2011_orallm11.log
-rw-r--r-- 1 root root 1359 Mar 26 20:14 3-26-2011_orallm11.log
-rw-r--r-- 1 root root 4586 Mar 28 20:13 3-28-2011_orallm11.log
-rw-r--r-- 1 root root 5038 Mar 29 19:40 3-29-2011_orallm11.log
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
How about writing your logs to a SMB share and setting the SMB option force user and force group on that folder.
ASKER
Very good suggestions. Thanks for everyone !
ASKER