remove all output without DEBUG=1 for cron use
[eg5120] / mqtt-pgsql.sh
1 #!/bin/sh -e
2
3 cd /home/dpavlin/eg5120
4
5 mosquitto_sub -h localhost -t eg5120 | while read json ; do
6         date=$( date +%Y-%m-%dT%H:%M:%S )
7         #echo -n $date ' '
8         echo $json | tee data/$date.json | tee /dev/shm/last-eg5120.json
9         psql --quiet -c "copy eg5120 (json) from '/dev/shm/last-eg5120.json'" eg5120
10 done