Question

Local Device Terminal Script launch but Digital Ocean Script does not launch, viceversa.

Posted April 10, 2019 362 views
Linux BasicsUbuntu 16.04

Basically , i ran a script on my droplet / virtual server. It ran well , i use digital ocean console. The next day i connected using the mac terminal, added SSH key, and bash ./thescript from the terminal, the script runs well, without stopping i went to digital ocean console terminal and open it up the script is not running.

I thought to myself maybe when i close the terminal on my mac it wont ran.

So i ran the script FIRST on DIGITAL OCEAN console.

Then connect to the droplet on my TERMINAL MAC local device.
Script does not have the output.

Thank you for your time.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hello,

If you need the script to run constantly even if you close your SSH session, I would recommend using screen.

To start a new screen session run:

screen -S SOME_NAME_HERE

Then inside the screen session run your script. After that to detach from the screen session press CTRL+A+D.

Then even if you close your terminal the script would remain running in the screen session.

If you need to attach back to the screen session run:

screen -R SOME_NAME_HERE

To list the available screen sessions run:

screen -ls

Hope that this helps!
Regards,
Bobby

Submit an Answer