bashloggingnohup

Can I change the name of `nohup.out`?


When I run nohup some_command &, the output goes to nohup.out; man nohup says to look at info nohup which in turn says:

If standard output is a terminal, the command's standard output is appended to the file 'nohup.out'; if that cannot be written to, it is appended to the file '$HOME/nohup.out'; and if that cannot be written to, the command is not run.

But if I already have one command using nohup with output going to /nohup.out and I want to run another, nohup command, can I redirect the output to nohup2.out?


Solution

  • nohup some_command &> nohup2.out &
    

    and voila.


    Older syntax for Bash version < 4:

    nohup some_command > nohup2.out 2>&1 &