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 -A
show thatscreen
is still running? Also, are you runningscreen -ls
as the same user thatscreen
originally starts as? – wingedsubmariner Sep 25 '14 at 19:25ps -A
does not listscreen
. As for your second question, I'm unsure. I'm runningscreen -ls
as root, and the job was assigned to root's crontab entry. That meansscreen
starts under root, right? – Macroeel Sep 25 '14 at 20:45run.sh
terminates, ending the screen session. If the server detaches from the starting terminal and goes into the background, thenrun.sh
will terminate, even though the server keeps running. – wingedsubmariner Sep 26 '14 at 00:39screen
may 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 -ls
it appeared that screen is shown only for user by whom it was created – Sergiy Kozachenko Oct 27 '17 at 11:03