2 ms·
I wonder why they didn't try the command a few times first from the shell. Anyone who's ever done 'ps | grep' will have noticed that the grep sometimes appears
by axod 17y ago
I wonder why they didn't try the command a few times first from the shell.
Anyone who's ever done 'ps | grep' will have noticed that the grep sometimes appears, sometimes doesn't.
Course you could do 'ps | grep | grep -v grep'
- deleted 17y ago[deleted]
- radu_floricica 17y agoIf it restarted every few hours and the test executed once a minute, then the bug would appear only once in a hundred executions. It's a good post, I think I could have made the same mistake easily.
- axod 17y agoIt takes me about 10 runs to get a line of output without the grep. Sometimes less. Try it :) EDIT: test.sh: for i in {1..1000} do ps | grep grep | wc -l done ./test.sh | sort | uniq -c 13 0 987 1 Which would indeed suggest 1.3%. Likely dependent on how quickly you're running it, if it's in memory already etc etc
- Afton 17y agoI'd never noticed it. I worked in a unix shell for a while, but I used to use ps piped to grep. But I suspect I often used 'grep -v' to filter the output anyway when I really needed just the non-grep lines.