0

I am running a startup script on Compute Engine,env is Ubuntu 16.04 , the script is running a screen and then running a process inside the screen.

All the echo lines are printed onto the Serial port 1 screen.

The problem is when I SSH into the machine there is no screen running.

I tested each of the lines to make sure they are working.

Can someone help me understand the problem?

The script:

#! /bin/bash
echo "going to sleep"
echo "starting bitcored"
screen -d -m -S testScreen 'bitcored'
echo "bitcored started"
TasosZG
  • 1,274
  • 1
  • 6
  • 13
Roie Beck
  • 1,113
  • 3
  • 15
  • 30
  • You expect the screen to keep running after the process you're running in the screen finishes, correct? Or is this process supposed to keep running? – jvdmr Feb 06 '19 at 12:39

1 Answers1

0

A screen closes automatically when the process inside it finishes. To keep it open, you need an active process inside. If the process you're running in it finishes for any reason, you could keep the screen busy by starting an interactive shell at the end of the process, for example:

screen -d -m -S testScreen "bitcored ; exec bash"

This will start bash once bitcored stops running, and will close the screen once bash is stopped, which under normal circumstances only happens manually.

jvdmr
  • 685
  • 5
  • 12
  • I understand, but bitcored does not stop, it is a full node server, it does not stop running... – Roie Beck Feb 06 '19 at 12:55
  • Does `bitcored` write any logs? Is this script executed as a user account that has the correct permissions to run `bitcored`? Is `bitcored` found in the `$PATH` variable `screen` provides (note: this is NOT usually the same $PATH as you get in your standard shell)? It might be better to write the full path to `bitcored` (ex. "/usr/bin/bitcored" or wherever it is found). – jvdmr Feb 06 '19 at 13:03
  • Hi @jvdmr , after viewing the logs the error is: bitcored: not found, I tried using the full path , but still I was not able to execute the commend during startup, only when SSH into the machine I am able to run the bitcored process.. it is really starge – Roie Beck Feb 13 '19 at 09:25