0

How can I launch a named Linux screen which executes a script at launch automatically?

So I want to use screen with these 2 conditions.

  1. The screen session should be named
  2. The screen session should be able to launch a script automatically inside of it. Let's say script.sh for example. So when the command I'm looking for is executed a screen session launches and the script.sh automatically launches inside the screen session.

Anyone? Please remember both conditions need to be fulfilled.

1
  • Are you referring to the UNIX screen command ?
    – xurei
    May 4, 2020 at 14:49

1 Answer 1

0

If you want an interactive screen :

screen -S myScreen /bin/bash --init-file ./screen_cmd.sh

If your script is going to stay alive (e.g. a server) :

screen -S myScreen /bin/bash ./screen_cmd.sh

You can reattach to the screen with

screen -r myScreen

Hope this helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .