0

I am trying to start a new screen in detached mode and run a shell script, which keeps running forever

My startup scrip contains following

screen -dmS live bash /home/mindedgescapital/projects/src/livetrade.sh

Screen command deosnot work in startup script. Getting following from logs

I want startup scrip to start a new detached screen and run my command in the detached screen. This is not happening.

`

cat /var/log/*.log | grep "google-startup-scripts.service" 
Jul  9 21:56:44 trainer systemd[1]: google-startup-scripts.service: Succeeded.
Jul 11 10:27:56 trainer systemd[1]: google-startup-scripts.service: Succeeded.
Jul 12 06:03:35 trainer systemd[1]: google-startup-scripts.service: Succeeded.
Jul 13 10:27:53 trainer systemd[1]: google-startup-scripts.service: Succeeded.
Jul 14 10:27:53 trainer systemd[1]: google-startup-scripts.service: Succeeded.
Jul 14 20:54:12 trainer systemd[1]: google-startup-scripts.service: Succeeded.
Jul 14 21:55:45 debian systemd[1]: google-startup-scripts.service: Succeeded.
Jul 14 21:55:45 debian systemd[1]: google-startup-scripts.service: Unit process 1038 (screen) remains running after unit stopped.
Jul 14 22:16:28 debian systemd[1]: google-startup-scripts.service: Succeeded.
Jul 14 22:16:28 debian systemd[1]: google-startup-scripts.service: Unit process 1012 (screen) remains running after unit stopped.
Jul 14 22:33:32 trainer systemd[1]: google-startup-scripts.service: Succeeded.
Jul 14 22:40:55 debian systemd[1]: google-startup-scripts.service: Succeeded.
Jul 14 22:40:55 debian systemd[1]: google-startup-scripts.service: Unit process 1049 (screen) remains running after unit stopped.

`

John Hanley
  • 74,467
  • 6
  • 95
  • 159
user93796
  • 18,749
  • 31
  • 94
  • 150
  • To start a new screen session in detached mode and to run $command you can use "screen -d -m $command" as per the below link https://www.liquidweb.com/kb/how-to-use-the-screen-command-in-linux/ – Kiran Kotturi Jul 17 '23 at 08:09
  • @KiranKotturi - The OP is running screen from a startup script that runs early in the system startup. I did not post an answer because I am not sure, but I do not believe that screen would work in this case. There is no terminal or user to attach to at that point in time. Do you have any experience in this case? – John Hanley Jul 17 '23 at 18:21

0 Answers0