linux - How to parse last value from CSV every five minutes? -
i need run script parse value csv every 5 minutes should not parse values time should last point.
really putting flesh on @hek2mgl's suggestion , implementing you.
i store last known length of logfile in file called lastlength
.
#!/bin/bash logfile=somelog.csv lastlen=lastlength # pre-set seek start of file... seek=0 # ... overwrite if there seen value [ -f lastlength ] && seek=$(cat lastlength) echo debug: starting offset $seek # update last seen length file - parameters "stat" differ on linux stat -f "%dz" "$logfile" > "$lastlen" # last line of file starting previous position dd if="$logfile" bs=$seek skip=1 2> /dev/null | tail -1
i using osx, if using linux, parameters stat
command in second last line different, probably
stat -c%s "$logfile" > "$lastlen"
i'll leave put crontab gets called every 5 minutes.
Comments
Post a Comment