Nohup redirect output to a file without -o parameter
Nohup is nice tool for runing an app in background. It can redirect output to a file with “-o” parameter. But this parameter has to write to last. For example
nohup myapp -o nohup.log
This prints all outputs to nohup.log file. But there is a problem. Some commands accepts it parameter. That means:
myapp -o nohup.log
“-o nohup.log” parameter doesnt passed to “nohup” command. For prevent this problem you must redirect output yourself. In linux there are two kind of outputs. Standard output and error output. You must redirect these to one file. The code is that:
nohup myapp -param1 -param2 -param3 > nohup.out 2> nohup.out &
“>” means “redirect standard output to that”, “2>” means “redirect error output to that”.“&” character means “run in background although I logout from shell”.
0 yorum