I have the following script under raspbian jessie:
file test.sh contains:
#!/bin/sh -e nohup sleep 321 & sleep 120 false exit 0 When run as normal user in a terminal session, I have the following situation:
pi@raspberrypi:~ $ ps -ejf |grep sleep pi 5073 5072 5072 4618 0 15:16 pts/1 00:00:00 sleep 321 pi 5074 5072 5072 4618 0 15:16 pts/1 00:00:00 sleep 120 and after the script exits, the sleep 321 process is reparented and still running as expected.
pi@raspberrypi:~ $ ps -ejf |grep sleep pi 5073 1 5072 4618 0 15:16 pts/1 00:00:00 sleep 321 Why doesn't this work in rc.local? The command run with nohup gets just killed.
pi@raspberrypi:~ $ ps -ejf |grep sleep root 450 449 449 449 0 15:45 ? 00:00:00 sleep 321 root 451 449 449 449 0 15:45 ? 00:00:00 sleep 120 and after 120 seconds the sleep 321 process just disappears.
It only works in rc.local when I replace false with false || true, so my guess is, it has something to do with running the script with -e, but why the difference between running test.sh from a terminal and rc.local at boot?