Can't create background process during sys-init stage
Bug #1463789 reported by
Vesnica
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
CirrOS |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I want to do something when os bootup, so first I create /etc/rc.local and write the following:
#!/bin/sh
screen -dmS Test sleep 300
nohup ls > /ls.log &
exit 0
Then:
sudo chmod +x /etc/rc.local
sudo reboot
After system reboot:
sudo screen -ls (show No socket in /var/screen/S-root)
sudo ls / (there is no ls.log)
I get the same result when I try to put the screen or nohup code in another init script(such as /etc/init.
To post a comment you must log in.
Ok, after hours googling and trial & error, I finally found the reason:
rc.local exit too fast, screen even have a chance to create socket before rc.local reach exit 0, so failure is inevitable.
Quick solution:
screen -dmS Test script -c 'sleep 300'
sleep 1
exit 0
Cheers