run command in a named background session using (screen or tmux)

screen -d -S "sessionname"  -m "command"
Example:
start nodemon in a seperate screen in the background inside path /var/www/cv.hg-system.com/node/ and execute server.js

screen -d -S nodemon -m cd /var/www/cv.hg-system.com/node/ && nodemon server.js

Start a named Session

# within a running screen: Press CTRL+A, ":sessionname "
screen -S "sessionname"

# view running screen's: screen -ls
# connect: screen -xS "sessionname"

Rename a Session

´Press Ctrl+A.
:sessionname "new sessionname"
´Press Enter

Deatatch with STRG + A and then STRG + D

Leave a Reply

Your email address will not be published.