I'm trying to start tomcat in such a way that it writes standard out to a text file.
I'm do this but I get a permission denied. Why is that?
[rob@machine1 bin]$ pwd
/usr/lib64/apache-tomcat-6.0.36/bin
[rob@machine1 bin]$ sudo ./startup.sh > console.log 2<&1
bash: console.log: Permission denied
Redirections are done by the current shell, which does not have sudo rights. When you want to write to console.log, you run sudo on a shell that can in turn do redirections:
sudo sh -c './startup.sh > console.log 2>&1'
Remarks:
I switched the direction of 2<&1
into 2>&1
.
You might want to include the redirections in your own startup script.