I want to monitor nginx access.log for malformed requests and notify myself about such cases.

To do this i have written following command:

tail -n0 -f access.log | grep --line-buffered '\{' | xargs sentry-cly -m

But this solution doesn't work for some reason. If i remove last pipe and end with grep only - i will see output as log file get new records.

I don't understand why xargs not executed. It will be the same if you replace sentry-cli with cat or echo.

Could you clarify why I have such behavior?

2 Answers 2


By default, xargs collects input until it has as much as it thinks it can safely pass to a single invocation of the utility (in this case sentry-cly -m). That means it'll wait until it's seen a large number of log messages, then run sentry-cly -m first message second message third message ... thousandth message .... To avoid this, use xargs -L1 sentry-cly -m -- the -L1 tells it to runsentry-cly -m for every line it reads (i.e. for each message).

(Similarly, xargs -L2 sentry-cly -m would wait until it'd gotten 2 messages then run sentry-cly -m "firstmessage" "secondmessage", then wait for the next two... You can see this by running xargs -L2 echo, and then typing lines into it and watching what gets echoed when.)


After some further investigation I found that following solution works: xargs -L 1.

  • 1
    Thanks for closing the loop on your question. Can you add a sentence to explain what that does and clarify whether that is the entire command?
    – fixer1234
    Dec 10, 2016 at 22:25
  • Gordon already provided a good exmplanation Dec 12, 2016 at 8:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .