Can't create background process during sys-init stage

Bug #1463789 reported by Vesnica
6
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.d/rc.sysinit)

Revision history for this message
Vesnica (vesnica) wrote :

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

Revision history for this message
Vesnica (vesnica) wrote :

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

Changed in cirros:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.