Cronjob - How To Output Stdout, And Ignore Stderr
Is it possible to output stdout to file, but ignore stderr? I have a Python script that uses sys.stderr.write(error) to output errors to stderr. I'd like to ignore these for this p
Solution 1:
The 2>&1 redirects stderr to stdout, appending it to the headlines.txt.
So, redirect stderr to /dev/null:
* * * * * /Users/me/bin/scrape-headlines /Users/me/proxies.txt >> /Users/me/headlines.txt 2> /dev/null
Solution 2:
You can use the "2" descriptor to control stderr separately and, e.g., redirect it to /dev/null:
* * * * * /Users/me/bin/scrape-headlines /Users/me/proxies.txt >> /Users/me/headlines.txt 2>/dev/null
Solution 3:
You can redirect stderr and stdout separately.
$ command 1> /some/file 2> /some/other/file
If you want to drop stderr, send it to/dev/null.
Post a Comment for "Cronjob - How To Output Stdout, And Ignore Stderr"