Posts: 6
Joined: Wed Feb 03, 2016 8:53 am

command via screen not starting at startup

Fri May 18, 2018 12:57 am

Hi. I reinstalled a raspberry with stretch (the minimum version). At startup I want to launch a command within a screen. To do this I put this in rc.local:

Code: Select all

su pi -c "(nohup screen -dmS somename bash -c 'the_command'  &)"
If I execute rc.local manually, the command works and the screen is started. However, if I restart the RPI no screens are present and the command is not running. I'm sure rc.local is executed as I also have another (non-screened) command before the screen command and that command is running fine.
I also tried to create a service using systemd with that exact same command, but this yields the exact same result: When i start the service manually via the command line (sudo systemctl start my.service), the service starts and the screen is running. But when I reboot the RPI , the service is started but the screen is again not present. If start the service manual directly after logging th screen appears normally

I used this exact same setup/command before in rc.local on my previous install, so I'm 100% sure this worked before. Something must be different now which is for whatever reason not starting the screen only at startup.

Any thoughts what this might be or how I can debug this further?

Posts: 6
Joined: Wed Feb 03, 2016 8:53 am

Re: command via screen not starting at startup

Sun May 20, 2018 8:04 am

To answer my own question: I found out that if I put a delay of x seconds (I've set it to 10 now) the screen is booted without any problem each time, like: (sleep 10; <the command>)&. To be extra sure it also starts without a user being logged in, so I'm 100% sure it's the sleep that solves my issue. So my guess is that there is some kind of dependency that is not ready and is required by screen (?) when rc.local is executed. This was also the reason why I tried with a systemd service, as I put the type to "idle" meaning it should start last, but this didn't work either. It's also strange that on previous version of raspbian (on the same device) I never experienced problems by starting my command in screened via rc.local. If anyone has a clue to what this dependency might be or has a cleaner solution feel free to reply :)

Return to “Raspbian”

Who is online

Users browsing this forum: No registered users and 28 guests