0

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

results in

192.168.0.109 - - [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?

jcdammeyer
  • 43
  • 1
  • 1
  • 3

1 Answers1

0

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 &
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • Thanks. My old Unix experience had me using >> for the stderr output rather than 2>. As soon as I used 2> it worked. – jcdammeyer Sep 27 '16 at 07:00
  • @jcdammeyer: `>>` opens the target file for *appending*; so filehandle 1 (stdout) would be appended to the target file, rather than truncating the file if it existed. – Martijn Pieters Sep 27 '16 at 07:05