Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Valve's dedicated server for the Source Engine (srcds_run) on Linux writes directly to the terminal, not stdout. I want to run it as an /etc/init.d daemon on Debian 6, and I'd like to redirect/capture the output to a file. How can I do that? And better yet, why would they output directly to the terminal, is there any benefit in doing that?

I suppose I could start another bash instance just for srcds_run, but that seems like a dirty solution, and I still don't know how to redirect the output.

share|improve this question

migrated from Nov 13 '12 at 9:34

This question came from our site for professional and enthusiast programmers.

The script maybe is writing to stderr instead of stdout, check this running the script as: ./script 2>some_file – h3nr1x Nov 12 '12 at 20:35
If it is truly opening and writing to /dev/tty or something equivalent, rather than stdout/stderr or cout/cerr, you might need to run it inside a screen session (or dtach or other similar tools). – twalberg Nov 12 '12 at 20:40
@h3nr1x I did try that already, it didn't work. Another odd annoying result is that if you run it as a background daemon you'll still get output in your terminal... – Salis Nov 12 '12 at 20:56
@twalberg is there a way to log to a file doing that though? I can't think of one, but I'm not terribly familiar with screen more than basics, and I've never heard of dtach – Salis Nov 12 '12 at 21:07
@twalberg nevermind, found it! – Salis Nov 12 '12 at 21:12

Due to twalberg's helpful comment, I found the answer

Run the program in screen, and use screenlog ( to capture output

share|improve this answer
screen -L -- command args... saves output of the command to screenlog.0. – J.F. Sebastian Sep 13 '14 at 20:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.