Code: Select all
setsid ./myscript.sh >/dev/null 2>&1 < /dev/null &
Code: Select all
setsid ./myscript.sh >/dev/null 2>&1 < /dev/null &
in bash (and most other shells) this is stdin/stderr/stdout redirection. The > /dev/null (same as 1>/dev/null) redirects stdout (which is file descriptor 1) to /dev/null. The 2>&1 means redirect all stderr (file descriptor 2) to file descriptor 1, which is already redirected to /dev/null. The </dev/null attaches /dev/null to stdin (fd 0). All of these let the script detach from all current input/output sources, and reattach to /dev/null.