3

In a terminal this works fine:

mosquitto_sub -h 192.168.178.20 -t tele/POW/SENSOR/# | jq '.ENERGY|.Power'

Every 10 seconds there is an output on screen because the device POW publishes it's sensor dates every 10 seconds. The output of mosquitto_sub (it's a JSON string) is piped to jq and jq shows only the value digit of the key 'Power'. Now I try to store the jq output (only the value) to a file 'output.log'.

mosquitto_sub -h 192.168.178.20 -t tele/POW/SENSOR/# | jq '.ENERGY|.Power' > output.log

is not working. What is going wrong?

JoergZ
  • 31
  • 1

1 Answers1

2

From the jq manual:

--unbuffered

Flush the output after each JSON object is printed 
(useful if you’re piping a slow data source into
jq and piping jq’s output elsewhere).
peak
  • 105,803
  • 17
  • 152
  • 177