How can I prevent nohup from creating the file ~/nohup.out?

Solution 1:

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>&1

redirection 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