mosquitto_sub is an MQTT version 3.1 client for subscribing to topics.

It works pretty well except it does not support to display a timestamp of the events.

The following “simple” command subscribes to all topics of the mosquitto MQTT server and executes the date command for each message.

mosquitto_sub -v -t /# | xargs -d$'\n' -L1 bash -c 'date "+%Y-%m-%d %T.%3N $0"'

Update: Thanks to Stewart C. Russell, who suggested to use ts from moreutils package, it can be achieved with a shorter expression:

mosquitto_sub -v -t /# | ts