Q: how check free space on particulat path

    Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

    • Q: how check free space on particulat path

      have got some problems cause new way of mounting storages
      have ask on DMM bord, but in case didn get answer will repeat also there

      DMM Board » Q: how check free space on particulat path
      what is best command to check free space on particulat path
      previously i have used that way
      root@Dream8k_M4:~#
      root@Dream8k_M4:~# df -h /media/cf/movie/
      Filesystem Size Used Available Use% Mounted on
      /dev/sdb1 14.8G 434.5M 14.4G 3% /autofs/5f312892-9319-412b-bf35-33f29f60ffa4
      root@Dream8k_M4:~#
      root@Dream8k_M4:~# echo `df -h /media/cf/movie/| awk {'print $4'}`
      Available 14.4G
      root@Dream8k_M4:~#


      but after changes in dreambox mounting method this command returns wrong value
      root@Dream8k_M3:~#
      root@Dream8k_M3:~# df -h /media/hdd/movie/
      Filesystem Size Used Available Use% Mounted on
      /dev/disk/by-uuid/0939759a-4059-4198-bb55-8636e29a4185
      465.7G 399.5G 66.1G 86% /media/hdd
      root@Dream8k_M3:~#
      root@Dream8k_M3:~# echo `df -h /media/hdd/movie/| awk {'print $4'}`
      Available 86%
      root@Dream8k_M3:~#


      there is solution what i found, but it is too complicated in compare with previous

      Quellcode

      1. CheckSpaceOnDest () {
      2. SpaceEnough=0
      3. DstInfo=`df -h $DstDir| tail -1`
      4. case "$DstInfo" in
      5. /*) if [ `echo $DstInfo| awk {'print $4'}| sed -e 's/\(^.*\)\(.$\)/\2/'` = "T" ] ||
      6. [ `df $DstDir| tail -1| awk {'print $4'}` -gt $(($fSize / 1024)) ]; then
      7. SpaceEnough=1
      8. fi
      9. ;;
      10. *) if [ `echo $DstInfo| awk {'print $3'}| sed -e 's/\(^.*\)\(.$\)/\2/'` = "T" ] ||
      11. [ `df $DstDir| tail -1| awk {'print $3'}` -gt $(($fSize / 1024)) ]; then
      12. SpaceEnough=1
      13. fi
      14. ;;
      15. esac
      16. }
      Alles anzeigen
      dm7080sstt; 2x dm8000sstt; dm7020s <- Diseq1x4 <- 3x Diseq1x10 <-
      Dishes:
      1.8m 36E;28E;23E;19E;16E;13E;7E
      1.6m 42E;36E
      1.0m 10/9E;5E;1W;8W
      1.0m 15W;22W;30W
      1.1m 4/5W;12W;18W;24W
      1.1m 53E;60E
      1.0m 75E
      TVs: Philips 46pfl9707s; Philips 42pfl9703h
    • RE: Q: how check free space on particulat path

      try this

      Quellcode

      1. root@dm800seGZ:~# df -h /media/HM320JI
      2. Filesystem Size Used Available Use% Mounted on
      3. /dev/disk/by-uuid/e22fdbf8-981e-4eaf-81f4-d34fee24b3b1
      4. 293.4G 33.2G 260.3G 11% /media/HM320JI

      Quellcode

      1. root@dm800seGZ:~# df -h /media/HM320JI | sed 's/Used//g' |awk '{print $3}'
      2. Available
      3. 260.3G
      4. root@dm800seGZ:~#

      Quellcode

      1. root@dm800seGZ:~# echo $(df -h /media/HM320JI | sed 's/Used//g' | awk '{print $3}')
      2. Available 260.3G
      3. root@dm800seGZ:~#
      Gruß Fred

      Die Dreambox ist tot, es lebe die Dreambox

    • you didnt catch problem reason

      for devices with short path string must be used comand "'{print $4}'"
      for devices with long path string must be used comand "'{print $3}'"
      long path string creates extra newline
      dm7080sstt; 2x dm8000sstt; dm7020s <- Diseq1x4 <- 3x Diseq1x10 <-
      Dishes:
      1.8m 36E;28E;23E;19E;16E;13E;7E
      1.6m 42E;36E
      1.0m 10/9E;5E;1W;8W
      1.0m 15W;22W;30W
      1.1m 4/5W;12W;18W;24W
      1.1m 53E;60E
      1.0m 75E
      TVs: Philips 46pfl9707s; Philips 42pfl9703h
    • RE: Q: how check free space on particulat path

      I know what you mean, I had the same problems with my script to "automount" my networkshares instaed using the networkbrowser

      That's my workaround:

      /usr/script/Test.sh

      Shell-Script

      1. #!/bin/sh
      2. DistDir=$1
      3. if [ "$(df -h $DistDir | awk '{print $4}' | grep -c '%')" != "0" ] ; then
      4. echo $(df -h $DistDir | sed 's/Used//g' | awk '{print $3}')
      5. else
      6. echo $(df -h $DistDir | awk '{print $4}')
      7. fi


      Quellcode

      1. root@dm800seGZ:~# df -h
      2. Filesystem Size Used Available Use% Mounted on
      3. .
      4. /dev/sda1 596.0G 302.3G 293.7G 51% /media/hdd
      5. /dev/disk/by-uuid/e22fdbf8-981e-4eaf-81f4-d34fee24b3b1
      6. 293.4G 33.2G 260.3G 11% /media/HM320JI
      7. 192.168.178.70:/media/hdd
      8. 916.9G 467.4G 449.5G 51% /media/DM7020
      9. .
      10. .
      11. root@dm800seGZ:~#
      Alles anzeigen


      Quellcode

      1. root@dm800seGZ:~# /usr/script/Test.sh /media/hdd
      2. Available 293.7G
      3. root@dm800seGZ:~# /usr/script/Test.sh /media/HM320JI/
      4. Available 260.3G
      5. root@dm800seGZ:~# /usr/script/Test.sh /media/DM7020/
      6. Available 449.3G
      7. root@dm800seGZ:~#
      Gruß Fred

      Die Dreambox ist tot, es lebe die Dreambox

      Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von Fred Bogus Trumper ()

    • similar, you are checking for `%` in the rsult me for `/` in last line

      propably i searching for single line solution, maibe some sed ?^&#@! is posible where replace first word if it starts with slash `/`

      there is my short version of free space check, but this is only for storages which cant have TB as returned value

      Quellcode

      1. CheckSpaceOnSrc () {
      2. SrcInfo=`df $SrcDir| tail -1`
      3. case "$DstInfo" in
      4. /*) SrcFreeSpace=`echo $SrcInfo| awk {'print $4'}`;;
      5. *) SrcFreeSpace=`echo $SrcInfo| awk {'print $3'}`;;
      6. esac
      7. }


      full code of /usr/script/move_recordings_from_CF.sh

      Shell-Script

      1. #!/bin/sh
      2. #
      3. # MartiniB #
      4. #
      5. SrcDir="/media/cf/movie/"
      6. #DstDir="/media/net/bigdisk/movie/"
      7. DstDir="/media/hdd/movie/"
      8. CfFreeSpaceIsEnough=4000000 # ~4Gb
      9. CheckSpaceOnDest () {
      10. SpaceEnough=0
      11. DstInfo=`df -h $DstDir| tail -1`
      12. case "$DstInfo" in
      13. /*) if [ `echo $DstInfo| awk {'print $4'}| sed -e 's/\(^.*\)\(.$\)/\2/'` = "T" ] ||
      14. [ `df $DstDir| tail -1| awk {'print $4'}` -gt $(($fSize / 1024)) ]; then
      15. SpaceEnough=1
      16. fi
      17. ;;
      18. *) if [ `echo $DstInfo| awk {'print $3'}| sed -e 's/\(^.*\)\(.$\)/\2/'` = "T" ] ||
      19. [ `df $DstDir| tail -1| awk {'print $3'}` -gt $(($fSize / 1024)) ]; then
      20. SpaceEnough=1
      21. fi
      22. ;;
      23. esac
      24. }
      25. CheckSpaceOnSrc () {
      26. SrcInfo=`df $SrcDir| tail -1`
      27. case "$DstInfo" in
      28. /*) SrcFreeSpace=`echo $SrcInfo| awk {'print $4'}`;;
      29. *) SrcFreeSpace=`echo $SrcInfo| awk {'print $3'}`;;
      30. esac
      31. }
      32. ExitIF () {
      33. # if night-time and free space on flash is enough
      34. [ `date +%H` -le 08 ] && CheckSpaceOnSrc && [ "$SrcFreeSpace" -ge "$CfFreeSpaceIsEnough" ] && exit
      35. }
      36. ExitIF
      37. for i in "$SrcDir"*.ts; do
      38. if [ -e "$i" ]; then
      39. echo "$i"
      40. fName=${i##*/}
      41. fName0=${fName%.ts}
      42. fSize=`ls -l "$i"| awk {'print $5'}`
      43. if [ ! $fSize = "0" ] && sleep 10 && [ $fSize = `ls -l "$i"| awk {'print $5'}` ]; then
      44. CheckSpaceOnDest
      45. if [ "$SpaceEnough" = "1" ]; then
      46. echo "cp $SrcDir$fName0"
      47. cp "$SrcDir$fName0"* "$DstDir"
      48. [ $fSize = `ls -l "$SrcDir$fName0".ts| awk {'print $5'}` ] && rm -f "$SrcDir$fName0"*
      49. fi
      50. fi
      51. fi
      52. ExitIF
      53. done
      Alles anzeigen
      dm7080sstt; 2x dm8000sstt; dm7020s <- Diseq1x4 <- 3x Diseq1x10 <-
      Dishes:
      1.8m 36E;28E;23E;19E;16E;13E;7E
      1.6m 42E;36E
      1.0m 10/9E;5E;1W;8W
      1.0m 15W;22W;30W
      1.1m 4/5W;12W;18W;24W
      1.1m 53E;60E
      1.0m 75E
      TVs: Philips 46pfl9707s; Philips 42pfl9703h
    • my solution works with TB as returned value too

      Shell-Script

      1. #!/bin/sh
      2. DistDir=$1
      3. if [ "$(df $DistDir | awk '{print $4}' | grep -c '%')" != "0" ] ; then
      4. echo $(df $DistDir | tail -1 | awk '{print $3}')
      5. else
      6. echo $(df $DistDir | tail -1 | awk '{print $4}')
      7. fi


      Quellcode

      1. root@dm800seGZ:~# df -h /media/HD203WI/
      2. Filesystem Size Used Available Use% Mounted on
      3. /dev/disk/by-uuid/e25e3fd2-268d-4b9b-bc9d-cf746286907e
      4. 1.8T 269.9G 1.6T 14% /media/HD203WI
      5. root@dm800seGZ:~# df /media/HD203WI/
      6. Filesystem 1K-blocks Used Available Use% Mounted on
      7. /dev/disk/by-uuid/e25e3fd2-268d-4b9b-bc9d-cf746286907e
      8. 1952906864 283024388 1669882476 14% /media/HD203WI
      9. root@dm800seGZ:~#



      Quellcode

      1. root@dm800seGZ:~# /usr/script/Test.sh /media/HD203WI/
      2. 1669882476
      3. root@dm800seGZ:~#
      Gruß Fred

      Die Dreambox ist tot, es lebe die Dreambox

      Dieser Beitrag wurde bereits 4 mal editiert, zuletzt von Fred Bogus Trumper ()

    • two and higher TB value has to been check separately cause it is too big for operatot `-gt`

      script:

      Shell-Script

      1. #!/bin/sh
      2. # MartiniB
      3. #
      4. DstDir="/media/net/bigdisk/movie/"
      5. dSize=`df -h $DstDir| tail -1| awk {'print $4'}`
      6. echo "$dSize"
      7. dSize=`df $DstDir| tail -1| awk {'print $4'}`
      8. echo "$dSize"
      9. [ "$dSize" -gt 111 ] && echo aaaa
      Alles anzeigen

      result:

      Quellcode

      1. root@Dream8k_M3:~# /usr/script/test_110518.sh
      2. 4.2T
      3. 4461818249
      4. sh: 4461818249: out of range
      5. root@Dream8k_M3:~#
      dm7080sstt; 2x dm8000sstt; dm7020s <- Diseq1x4 <- 3x Diseq1x10 <-
      Dishes:
      1.8m 36E;28E;23E;19E;16E;13E;7E
      1.6m 42E;36E
      1.0m 10/9E;5E;1W;8W
      1.0m 15W;22W;30W
      1.1m 4/5W;12W;18W;24W
      1.1m 53E;60E
      1.0m 75E
      TVs: Philips 46pfl9707s; Philips 42pfl9703h

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von MartiniB ()