Last active
February 6, 2023 16:18
-
-
Save tihasdop/c9817257980675133a5d597215b35e3d to your computer and use it in GitHub Desktop.
nohup wrapper to run a command separate from the TTY and without any output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -z "$1" ] || [ "$1" = '--help' ]; then | |
echo 'nohup wrapper to run a program separate from the TTY' \ | |
'and without any output' | |
echo | |
echo "Read 'man nohup' for further info" | |
exit 1 | |
elif echo "$1" | grep -q '/'; then | |
if [ ! -f "$1" ]; then | |
echo "ERROR: '$1' is not found" | |
exit 2 | |
elif [ ! -x "$1" ]; then | |
echo "ERROR: '$1' is not executable" | |
exit 3 | |
fi | |
elif ! which "$1" >/dev/null 2>&1; then | |
echo "ERROR: '$1' is not found in PATH" | |
exit 4 | |
fi | |
nohup $* >/dev/null 2>&1 & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment