jcdammeyer jcdammeyer - 1 year ago 77
Python Question

redirecting python -m CGIHTTPserver 8080 to /dev/null

The standard > /dev/null and >> /dev/null don't work when a computer sends a GET to the task.
pi@raspberrypi:~/server $ python -m CGIHTTPServer 8080 &

results in - - [26/Sep/2016 23:14:48] "GET /cgi-bin/DS1822remote.py HTTP/1.1" 200 -

As I've put the python app into the background with the '&' I'd like to also see the GET requests vanish.

How do I do this or is it even possible?

Answer Source

You need to redirect stderr, not stdout; best to redirect both with:

 python -m CGIHTTPServer 8080 > /dev/null 2>&1 &

If you still want to expose stdout (to see the start-up message, for example), use:

 python -m CGIHTTPServer 8080 2> /dev/null &
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download