I want to start a python webserver in the background and log all of its output to file.
Instead the the servers output appears in the terminal.
Even tho i guess this is pretty basic ... I've got no clue why this isnt working.

server.py (from the python doc):

import SimpleHTTPServer
import SocketServer

PORT = 8000

Handler = SimpleHTTPServer.SimpleHTTPRequestHandler

httpd = SocketServer.TCPServer(("", PORT), Handler)

print "serving at port", PORT

start command:

python http_server.py > server.log &

Why does this not output to the file and how would I do it correctly?

  • 1
    Are you seeing output to that shell's terminal or elsewhere? – Jeff Schaller Mar 23 at 12:18
  • @JeffSchaller Yes exactly. Its in the terminal instead. – Gerrit Sedlaczek Mar 23 at 12:20
  • 6
    Perhaps the program is writing to stderr; you're only redirecting stdout. Try python http_server.py &> server.log & – Emmanuel Rosa Mar 23 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.