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.

I have a python server running as a daemon on Debian 4.1. I want to view its stdout, so I thought I should bring it to foreground somehow. How can I do that?

share|improve this question
add comment

4 Answers 4

up vote 4 down vote accepted

If you daemon running in the background and don't have any option to be run in the foreground or to log in a file, I really don't think that it will write something on stdout (that wouldn't be nice).
If it really do that, I would suggestion to launch it with a redirection to a log file like:

mydaemon > /var/log/mydaemonlogfile
share|improve this answer
    
Yes, this solved my issue. It wasn't what I was looking for (since this requires restarting the server), but it fixed my need. Thanks. –  Hosam Aly Jul 15 '09 at 13:17
    
BTW, it was useful to know that I could use &> to redirect all output (including stderr) to my log file. –  Hosam Aly Jul 15 '09 at 13:18
    
If you want to see stdout without relaunching the daemon, you may try pasky.or.cz/~pasky/dev/retty but take care. –  radius Jul 15 '09 at 13:39
add comment

If the deamon is writting anything to stdout it must be sending it to a log file. If you want a real-time view of what it's logging then:

tail -f the_log_file

Will do the trick. That's how one normally monitors what a service on Linux is up to in real-time.

share|improve this answer
    
Yes, that's what I would normally do, but the point is that the daemon is not writing to a log file in this particular case. –  Hosam Aly Jul 15 '09 at 15:04
add comment

"Daemonizing" procedure always detaches from the terminal, and stdin,stdout,stderr descriptors are closed. This means that there's no way to bring it back, except for some special functionality, such as:

  1. Log files
  2. Special application console (separate program - like MySQL server's client). This can be also a telnet server bound on some port
share|improve this answer
add comment

Unlike processes that are subprocesses within your shell, which you can fg and bg at will, daemons are usually subprocesses of init. Good daemons will have their stdout and stderr redirected to syslog or directly to a log file, though. If that is not the case, and you need to debug a currently running daemon and cannot or do not want to restart it, try strace. That should at least give you some insight into what is going on.

share|improve this answer
    
That's exactly the case I am having. But I am not sure how strace can help me... –  Hosam Aly Jul 15 '09 at 15:07
add comment

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.