I am running a java application using the nohup command.
nohup java -jar test.jar
I am using log4j to write output from my application. In the log4j.properties file, I have a file this writes the output. The problem is that I have the same output twice in nohup.out and in test.log(I have configured this in the log4j.properties file)
Is there a way of disabling the writing of the output to nohup.out?
The nohup command only writes to nohup. out if the output would otherwise go to the terminal. If you have redirected the output of the command somewhere else - including /dev/null - that's where it goes instead.
When using nohup and you put the task in the background, the background operator ( & ) will give you the PID at the command prompt. If your plan is to manually manage the process, you can save that PID and use it later to kill the process if needed, via kill PID or kill -9 PID (if you need to force kill).
You can delete it if you don't want what's in it, but if the program that created the file is still running, then the disk space won't actually be reclaimed until the program exits.
nohup is a POSIX command which means "no hang up". Its purpose is to execute a command such that it ignores the HUP (hangup) signal and therefore does not stop when the user logs out. nohup.
You can redirect nohup output to /dev/null.
nohup java -jar test.jar >/dev/null
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