Fork current process into the background
So i wanted to create a simple script that had to go into the background, but I did not want to call
nohup command &
Instead I wanted to let the program do that itself. I found that if we are dealing with simple scripts then this is a quick and dirty way to achieve this. Should work well with any distro.
#!/bin/bash if [ "$1" != "nohupme" ] #just to fork it to background then nohup $0 nohupme 2>&1 > $0.log & else #actual program echo "Program goes here" fi