-1

I want to run "screen" on a debian linode server, starting up over a ssh terminal window. I'd like a shell script to start and detach a screen, so that a process can continue when I log off. I'd also like the logging file screenlog.0 to be produced, so that there's a record if the process crashes.

But there's a problem in getting the log file to write. Locally, on a mac terminal window,

% screen -dm -L sh -c 'echo hello'

works fine, "hello" gets written to screenlog.0. But the same command issued in a ssh window to the server executes, but nothing gets written. However, if in that window I go into screen,

% screen -L

and then do some stuff, the activity is written to screenlog.0 (on the server).

What am I missing?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
rshaw
  • 111
  • 1
  • 3

1 Answers1

1

It turns out that the screen() command can have problems. The above command sends no output to screenlog.0 under 'Debian GNU/Linux 9 (stretch)' , while 'Ubuntu 14.04.1 LTS' writes the odd message, "error: could not start server! try running as root!", to screenlog.0, even when running as root. 'Linux Mint 18.1' and MacOSX run correctly.

I was advised to use the venerable unix command "nohup" to solve my problem of detaching a process and logging its output, even when you close the ssh connection. Ordinarily, when you close a terminal window, the signal SIGHUP is sent to any processes that were started there. But

% nohup myprog > logfile.txt &

works perfectly. Old way, good way.

rshaw
  • 111
  • 1
  • 3