I wish to run TOMCAT with my current user's permissions, not the root's environment variables.
vagrant@dev:~/Workspace/eurekastreams$ echo $JAVA_OPTS
-Xmx1024m -XX:MaxPermSize=128m -Dlog.home=/home/vagrant/Workspace/software/
I tried, vagrant$>sudo -E /etc/init.d/tomcat7 start.
However, my software is not logging to the /home/vagrant/Workspace/software directory, which means, I believe, that the JAVA_OPTS environment variable was not set.
Am I understanding sudo -E correctly that it will perform a command with env vars of the current user?
From man sudo :
-E, --preserve-env
Indicates to the security policy that the user wishes to preserve their existing
environment variables. The security policy may return an error if the user does
not have permission to preserve the environment.
Thus yes, the -E will execute the command with the current environment variables.
Unless you use the -u parameter with sudo, it will run your command as root. How about this:
sudo -u yourusername -l /etc/init.d/tomcat7 start
-u username : run the command as specified user -l : make it a login shell, reading starup scripts such as .bashrc, which, I assume, is where you set your environment variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With