Skip to content

Instantly share code, notes, and snippets.

@ericxyan
Last active January 21, 2019 18:22
Show Gist options
  • Save ericxyan/3c748e37d683c840fb6eef8dc91549b1 to your computer and use it in GitHub Desktop.
Save ericxyan/3c748e37d683c840fb6eef8dc91549b1 to your computer and use it in GitHub Desktop.
< /dev/null

< /dev/null is used to instantly send EOF to the program, so that it doesn't wait for input (/dev/null, the null device, is a special file that discards all data written to it, but reports that the write operation succeeded, and provides no data to any process that reads from it, yielding EOF immediately). & is a special type of command separator used to background the preceding process.

nohup myscript.sh >myscript.log 2>&1 </dev/null &
# |               ^^^^^^^^^^^^^ ^^^^ ^^^^^^^^^^ ^
# |                    |           |      |     run in background
# |                    |           |      |     
# |                    |           |   don't expect input
# |                    |           |   
# |                    |           redirect stderr to stdout
# |                    |           
# |                    redirect stdout to myscript.log
# |
# keep running the command no matter the connection is lost or you logout
# show special characters
cat -v
cat -A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment