Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 stackoverflow.com Nov 13 '12 at 9:34

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

1  
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

1 Answer 1

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

Run the program in screen, and use screenlog (http://web.mit.edu/gnu/doc/html/screen_17.html) to capture output

share|improve this answer

Your Answer

 
discard

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.