Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want an unprivileged user to be able to restart tomcat on my server. So I edited /etc/sudoers as follows

username  ALL=/etc/init.d/tomcat6

However, when the user runs /etc/init.d/tomcat6 restart he gets this error:

Starting tomcat server...
 touch: cannot touch `/var/tomcat6/logs/catalina.out': Permission denied
/var/tomcat6/bin/catalina.sh: line 314: /var/tomcat6/logs/catalina.out: Permission denied

How do I allow this user to run tomcat without giving him write permission on the log file /var/tomcat6/logs/catalina.out ?

[root@jsp1 ~]# ll /var/tomcat6/logs/catalina.out
-rw-r--r-- 1 root root 272669097 Feb 27 21:50 /var/tomcat6/logs/catalina.out
share|improve this question
4  
This may be redundant, but you were unclear in your question--are you running the service command with sudo? I.e., sudo /etc/init.d/tomcat6? – Andrew M. Feb 27 '11 at 21:00
1  
no, I wasn't running the command using sudo. Sorry my bad... It works just fine now with sudo. So thanks a lot Redmumba :) – Zenet Mar 1 '11 at 10:35
up vote 5 down vote accepted

Make sure to actually run the command with sudo when you try it.

share|improve this answer

I wanted to use the service command for this, so I came up with this:

%tomcat7 ALL=NOPASSWD:/usr/sbin/service tomcat7*

This allows everyone in tomcat7-group to start/stop/restart the tomcat service with sudo service tomcat7 <command> without typing their password.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.