SheffieldMLtracking / data-pipeline

Bee tracker automatic data pipeline scripts
https://github.com/SheffieldMLtracking/BBSRC_ohio/issues/20
GNU General Public License v3.0
0 stars 0 forks source link

Delete data when storage is full? #3

Open Joe-Heffer-Shef opened 2 weeks ago

Joe-Heffer-Shef commented 2 weeks ago

How do we prevent the remote machines from filling up their storage? Can we check the disk usage and act accordingly?

Is this a good idea? How to do it?

Could we modify things a little so it checks how much storage space is left, and if it falls below a certain threshold that would trigger data deletion (after syncing)?

we can probably use the du disk usage tool to check how much data has been collected and use that to trigger a clean-up operation.

ssh raspberry30 -t "du /home/pi/beephotos --summarize"
raspberry_ids=$(seq 30 35)
for i in $raspberry_ids
do
  host="raspberry$i"
  echo $host
  ssh $host -t "du /home/pi/beephotos --summarize && df -hT | grep ext4"
done

Possible approach: https://stackoverflow.com/a/71626685

We could also use the file system disk space df tool

df / --human-readable

The RPI SD card slot is called /dev/mmcblk0p2 https://github.com/raspberrypi/noobs/wiki/NOOBS-partitioning-explained

Joe-Heffer-Shef commented 3 days ago

Get disk usage ratio https://askubuntu.com/a/1206033

pi@raspberry31:~ $ df / --output='pcent'
Use%
 21%
pi@raspberry31:~ $ df / --output='pcent' | grep --only-matching "[0-9]*"
21