5

iam using nohup in my project. Is there a possibility get the Output of the program to the console and to the file at the same time while using nohup?

With "tee"i had no sucess:

nohup ./programm 2>&1 | tee Output.txt

thanks for help

user3707049
  • 65
  • 1
  • 1
  • 11

1 Answers1

8

Try this to run and log the output in file.

nohup ./program  > Output.txt | tail -F Output.txt &

If you want to run it in background:

nohup ./program  > Output.txt &
Manish Singh
  • 518
  • 3
  • 13
  • Don`t work. Writes only in the file. But on the Console (stdout) is no Output. – user3707049 Nov 04 '16 at 11:20
  • that is the solution i tried before. The Problem is at the end of the program the Output of the console stops and dont goes back to the Linux user prompt. So i have to shutdown the Report with strg -c to go back to the Linux user prompt. I Need a solution where it goes back to the Linux user prompt when the program is finish. – user3707049 Nov 04 '16 at 12:59
  • I think its quiet confusing.. you want this to run tail in background so that you can access the console prompt again. Is it ? – Manish Singh Nov 05 '16 at 14:37
  • Yes, but i read the prompt with a own written Software tool from another pc. So when the tool on Linux console with tail -f is finished, i have to Close the prompt with strg -c to go back to the Linux user prompt. I want to avoid the STRG-C Command because i want to set new commands to the Linux console with my own written software – user3707049 Nov 07 '16 at 07:27
  • I have edited my answer. Please have a look whether it is working by putting an & at the end to make it runnable as background. I hope it should work – Manish Singh Nov 08 '16 at 04:36
  • Thanks this solution works for me.!!! Can you explain what the command excatly do? – user3707049 Nov 08 '16 at 15:11
  • It actually logs into ouptut.txt and tail will be used to read the file but this reading process will be executed in background. this '&' means run the process in background. – Manish Singh Nov 09 '16 at 05:29