How can I prevent nohup from creating the file ~/nohup.out?
I use the command $ nohup ... to start an application in the background so that I can close the terminal window afterwards.
Upon execution it creates the file ~/nohup.out.
Example:
orschiro@x230:~$ nohup /bin/bash -c "sleep 15 && python3 /home/orschiro/bin/show_state.py"
nohup: ignoring input and appending output to 'nohup.out'How can I prevent nohup from creating nohup.out?
1 Answer
You may redirect the output anywhere you like, for example:
nohup /bin/bash -c "sleep 15 && python3 /home/orschiro/bin/show_state.py" >/dev/null 2>&1redirection prevents the default output file nohup.out from being created. /dev/null is oblivion, so if you don't want the data at all, send it there.
In bash you can abbreviate >/dev/null 2>&1 to &>/dev/null
For programs I use often I make an alias (and add it to my .bashrc) for example
alias show_state='nohup /bin/bash -c "sleep 15 && python3 /home/orschiro/bin/show_state.py" >/dev/null 2>&1'Now all I have to type is show_state