Solved:
I solved this problem by introducing a delay before executing the script: @reboot sleep 60; /root/start_server.sh
On Ubuntu 14.04, I have a crontab entry set to run on reboot:
@reboot /root/start_server.sh
And here's start_server.sh:
screen -dmS server bash -c "cd server ; ./run.sh"
When the system starts up, run.sh is indeed executed, and the server remains up, but there are no sessions when I type screen -ls. Because of this, I can't access my server process after boot.
What's happening to the session I named "server"? If it's being terminated somehow, how do I prevent that?
I've tried adding exec bash to start_server.sh as per the answer here, but it had no effect.
ps -Ashow thatscreenis still running? Also, are you runningscreen -lsas the same user thatscreenoriginally starts as? – wingedsubmariner Sep 25 '14 at 19:25ps -Adoes not listscreen. As for your second question, I'm unsure. I'm runningscreen -lsas root, and the job was assigned to root's crontab entry. That meansscreenstarts under root, right? – Macroeel Sep 25 '14 at 20:45run.shterminates, ending the screen session. If the server detaches from the starting terminal and goes into the background, thenrun.shwill terminate, even though the server keeps running. – wingedsubmariner Sep 26 '14 at 00:39screenmay be doing. Try it with the old, unpatched version of bash that was on your system. That would be the quickest way to rule that out. – DocSalvager Oct 08 '14 at 08:55sudo screen -lsit appeared that screen is shown only for user by whom it was created – Sergiy Kozachenko Oct 27 '17 at 11:03