2

I have an application hosted by jsvc on Centos 6. There are a number of logs created along with it. My problem is that jsvc is creating those logs with 077 permissions which are not accessible by anybody but root. The logs should be readable by anybody.

jsvc.exec -server -Xms1024M -Xmx2048M -cp myapp.jar -errfile /var/log/myapp/error.log -wait 60 com.myawesomecompany.mysuite.myapp

-rw------- 1 root root   370 Feb 26 16:03 error.log

How can I override the default permissions so that any new logs that are generated will have 022 permissions?

user3063045
  • 2,019
  • 2
  • 22
  • 35

2 Answers2

5

jsvc has a -umask option since version 1.0.8 (see this JIRA issue).

Please note the -umask option takes a decimal and complemented value, for instance if you want 644, you have to complement it (777 - 644 = 133), and then convert the octal value to a decimal one (133 -> 91)...

nicoulaj
  • 3,463
  • 4
  • 27
  • 32
0

You can convert octal to decimal using printf. For example

jsvc -umask $(printf '%d' 022)
jsvc -umask $(printf '%d' $(umask))
Nicholas Sushkin
  • 13,050
  • 3
  • 30
  • 20