Created
October 22, 2016 07:41
-
-
Save Galarius/6643c0bc3a145d6b5492a1e4c5386ae7 to your computer and use it in GitHub Desktop.
Self-detaching shell script
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/bash | |
# self-detach.sh | |
# Self-detaching shell script | |
#------------------------------------------ | |
if [ -z "$_DETACHED_" ] | |
then | |
# Run this script silently in background | |
# mode with low priority | |
_DETACHED_=1 nohup nice sh $0 &>/dev/null | |
exit 0 | |
fi | |
#------------------------------------------ | |
# Perform some task here | |
# ... | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment