]> git.somenet.org - pub/jan/pyWH1080.git/blob - cron.sh
remove human readable wind dir.
[pub/jan/pyWH1080.git] / cron.sh
1 #!/bin/bash
2
3 # This script is run every min and does all the data gathering.
4
5 MYPWD=$(pwd)
6
7 mkdir -p /tmp/wh1080/device
8 START_TS="$(date --utc -Isec)"
9 echo "** cron.sh: started: ${START_TS}"
10 echo "${START_TS}" >/tmp/wh1080/cron.sh.start.ts
11 echo "${START_TS}" >/tmp/wh1080/device/last.ts
12
13
14
15 # cleanup old history data.
16 cd /tmp/wh1080/device
17 find . -type f -mmin +1440 -delete >/dev/null 2>&1
18 find . -empty -delete >/dev/null 2>&1
19 cd /tmp/wh1080
20
21
22 # get data
23 echo "** cron.sh: processing"
24 mkdir -p /tmp/wh1080/device/history
25 cd "$MYPWD"
26 ./fetch_data.py >/tmp/wh1080/device/last.json.new
27
28 mv /tmp/wh1080/device/last.json.new /tmp/wh1080/device/last.json
29 cat /tmp/wh1080/device/last.json >"/tmp/wh1080/device/history/data.$(cat /tmp/wh1080/device/last.ts).json"
30 cd /tmp/wh1080/device/history
31 echo "[$(ls --format=commas -Q)]" >/tmp/wh1080/device/history.json
32
33
34
35 # finish
36 ln -snf /tmp/wh1080.cron.sh.log /tmp/wh1080/cron.sh.log
37
38 END_TS="$(date --utc -Isec)"
39 echo "${END_TS}" >/tmp/wh1080/cron.sh.stop.ts
40 echo "** cron.sh: DONE: ${END_TS}"