Как создать screen, если тот отсутствует?

Я создаю screen такой командой:

screen -dmS screen_name command

Но если выполнить эту команду несколько раз, тогда будет создано несколько одноименных screen.

Я хочу, чтобы screen не создавался, если уже имеется screen с таким именем.

Конечно можно сделать дополнительную проверку:

if screen -ls | grep -q "\.screen_name\s"; then
  exit 0;
fi
screen -dmS screen_name command

Но возможно ли это сделать каким либо из аргументов команды screen?

Я видел, что существуют аргументы по типу таких:

-d -r
    Reattach a session and if necessary detach it first. 
-d -R
    Reattach a session and if necessary detach or even create it first. 
-d -RR
    Reattach a session and if necessary detach or create it. Use the first session if more than
    one session is available. 
-D -r
    Reattach a session. If necessary detach and logout remotely first. 
-D -R
    Attach here and now. In detail this means: If a session is running, then reattach. If necessary
    detach and logout remotely first. If it was not running create it and notify the user. This is
    the author's favorite. 
-D -RR
    Attach here and now. Whatever that means, just do it. 
    Note: It is always a good idea to check the status of your sessions by means of "screen -list". 

Но я хочу создавать screen в "detached" режиме, а эти все аргументы делают attach.


Ответы (0 шт):