make nohup write other than nohup.out

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



make nohup write other than nohup.out



I've been using below command to make tail to write nohup.out and also print the output on the terminal.


nohup train.py & tail -f nohup.out



However, I need nohup to use different file names.



When I try


nohup python train.py & tail -F vanila_v1.out



I'm getting following error message.



tail: cannot open 'vanila_v1.out' for readingnohup: ignoring input and appending output to 'nohup.out': No such file or directory


tail: cannot open 'vanila_v1.out' for readingnohup: ignoring input and appending output to 'nohup.out': No such file or directory



I also tried
nohup python train.py & tail -F nohup.out > vanila_v1.txt


nohup python train.py & tail -F nohup.out > vanila_v1.txt



Then it doesn't write an output on stdout.



How do I make nohup to write other than nohup.out? I don't mind simultaneously writing two different files. But to keep track of different processes, I need the name to be different.
Thanks.


nohup.out




1 Answer
1



You need to pipe the STDOUT and STDERR for the nohup command like:


STDOUT


STDERR


$ nohup python train.py > vanila_v1.out 2>&1 & tail -F vanila_v1.out



At this point, the process will go into the background and you can use tail -f vanila_v1.out. That's one way to do it.


tail -f vanila_v1.out



A little more information is available here for the STDOUT and STDERR link. Here is another question that uses the tee command rather that > to achieve the same in one go.


STDOUT


STDERR


>





Hi Thanks for the comment but when I try your command, it doesn't print out on stdout.
– Aaron
Aug 9 at 23:48





The reason why I used tail was to print out on stdout.
– Aaron
Aug 9 at 23:48





@Aaron The full command line would be nohup python train.py > vanila_v1.out 2>&1 & tail -F vanila_v1.out. There's a critical point here that I think you're missing: the parts before and after the & are completely independent commands (with the first being run in the background). Thus, you do the redirects for the first command as part of the first command, and have the second (tail) command read from wherever the first got redirected to.
– Gordon Davisson
Aug 10 at 2:42


nohup python train.py > vanila_v1.out 2>&1 & tail -F vanila_v1.out


&


tail






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard