News How to Use Nohup to Run Linux Scripts Unattended

w_barath

Distinguished
Aug 22, 2011
46
17
18,535

Bash:
$ autossh user@host -- screen -x -R -t "Title" -h 10000;

This will let your remote scripts survive disconnects, and when the reconnect occurs you'll have your display back exactly how it left off. Super handy for WiFi and/or mobile connections.

It's also great if you have a number of remote hosts to admin and you have something like a google free tier compute node that you can shell into and then open multiple screen "windows" to all those remotes. Then you only have to connect to the one screen session to have stable network access to all those other hosts via CRTL-A 0..9 with nice little labels at the bottom of the screen to remind you which is which.

21KjGAO.png


Code:
user@localhost:~$ ssh user@remote.host -- cat \~/.screenrc
# .screenrc
defscrollback 10000
startup_message off

# mouse scrollback:
termcapinfo xterm* ti@:te@

# window list:
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G}"

# mouse can switch windows
mousetrack on

# prevent xoff
bind s split

P.S. view response in the forum for a screenshot.

P.P.S. @Les: echo $(( n++ ));
 
Last edited: