Bash:
$nohup sleep 10 &
but when I close the terminal:
Any ideas? ideally I want to run Mongodb in the background.
I'm on OSX 10.8.5, and can confirm:
nohup base64 /dev/urandom &
Terminal.app-based apps (eg TotalTerminal) spawns the process under the shell session, not under launchd
, which would be the expected/equivalent to linux behaviour.
On the other hand, iTerm2.app was able to run the same command under launchd
, and it kept alive after the shell session was closed. It implements some special trick though:
─┬◆ 00001 root /sbin/launchd
├─┬◆ 00245 albanj01 /sbin/launchd
│ └─┬◆ 21533 albanj01 /Applications/iTerm.app/Contents/MacOS/iTerm2 -psn_0_94628409
│ └─┬◆ 04684 albanj01 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server /Applications/iTerm.app/Contents/MacOS/iTerm2 --launch_shell
│ └─┬◆ 04685 albanj01 -zsh
│ └──◆ 04759 albanj01 base64 /dev/urandom
My colleague on my side has tried the same thing on OSX 10.10.x and Terminal.app spawned the nohup
process under launchd
, suggesting that potentially they have fixed it between 10.8.x-10.10.x .
I tried this on Snow Leopard, and the dialog popped up and complained that it was going to kill sleep, but when I checked via ps -eaf
sleep was still running.
bill$ ps -eaf | grep sleep
501 11806 1 0 0:00.00 ?? 0:00.01 sleep 1000
501 11811 2628 0 0:00.00 ttys001 0:00.00 grep sleep
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With