Skip to content

Instantly share code, notes, and snippets.

@mertenvg
Created October 1, 2012 20:58
Show Gist options
  • Save mertenvg/3814370 to your computer and use it in GitHub Desktop.
Save mertenvg/3814370 to your computer and use it in GitHub Desktop.
Nohup with command sequence
# Create a test.pid file containing the pid of the sh process.
# Run the main command. Example: Sleep for 15 seconds.
# Then remove the pid file once the main command process is ended or killed.
$ nohup sh -c "sleep 15; rm test.pid" >/dev/null 2>&1 & echo $! > test.pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment