Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: Dreamboard. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

1

Freitag, 17. Februar 2012, 21:03

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

Zitat

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 method returns wrong value

Zitat

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:~#
Receivers: dm7080sstt; 2x dm8000sstt; dm7020s <-Diseq1x4(1.0)<-3x Diseq1x10(1.1)<-
Dishes:
1.8m + 42E;36E;28E;23E;19E;16E
1.6m + 13E;10/9E;5E;1W;8W
1.6m + 75E;85E
1.1m + 53/55E;60E
1.1m + 12W;18W;24W
1.0m + 15W;22W;30W
1.0m + 7E;4/5W
TVs: Philips 46pfl9707s; Philips 42pfl9703h

2

Mittwoch, 22. Februar 2012, 16:23

I would simply use grep to get rid of the unneeded lines and then the argument number for awk would be fixed again - something like this:

df -h /media/hdd/movie/ | grep % | grep -v Files| awk {'print $3'}
Einmal Rupert und Zurück

3

Mittwoch, 22. Februar 2012, 21:40

@Gutemine
TANKS for reply, but still wrong value returned

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
root@Dream8k_M3:~# 
root@Dream8k_M3:~# df -h /media/cf/movie/                                    
Filesystem                Size      Used Available Use% Mounted on
/dev/sdb1                14.8G      1.7G     13.1G  12% /autofs/e5d8b110-43d4-4b58-8bfa-f79be6d91a69
root@Dream8k_M3:~# 
root@Dream8k_M3:~# echo `df -h /media/cf/movie/ | grep % | grep -v Files| awk {'print $3'}`
1.7G
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    428.9G     36.8G  92% /media/hdd
root@Dream8k_M3:~# 
root@Dream8k_M3:~# echo `df -h /media/hdd/movie/ | grep % | grep -v Files| awk {'print $3'}`
36.8G
root@Dream8k_M3:~#



currently have fixed for self by create inside function in the script
for storages which cant have 2TB and more

Quellcode

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

but for bigger storages same way just check before TB

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
CheckSpaceOnDest () {
	SpaceEnough=0
	DstInfo=`df -h $DstDir| tail -1`
	case "$DstInfo" in
	/*)	if [ `echo $DstInfo| awk {'print $4'}| sed -e 's/\(^.*\)\(.$\)/\2/'` = "T" ] ||
		   [ `df $DstDir| tail -1| awk {'print $4'}` -gt $(($fSize / 1024)) ]; then
			SpaceEnough=1
		fi
	;;
	*)	if [ `echo $DstInfo| awk {'print $3'}| sed -e 's/\(^.*\)\(.$\)/\2/'` = "T" ] ||
		   [ `df $DstDir| tail -1| awk {'print $3'}` -gt $(($fSize / 1024)) ]; then
			SpaceEnough=1
		fi
	;;
	esac
}


to able make all easier i miss some sed @&^#$ to remove first word only when it begins with /
then awk {'print $3'} will work for any source

full code of /usr/script/move_recordings_from_CF.sh

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
#
# MartiniB #
#

SrcDir="/media/cf/movie/"
#DstDir="/media/net/bigdisk/movie/"
DstDir="/media/hdd/movie/"

CfFreeSpaceIsEnough=4000000 # ~4Gb

CheckSpaceOnDest () {
	SpaceEnough=0
	DstInfo=`df -h $DstDir| tail -1`
	case "$DstInfo" in
	/*)	if [ `echo $DstInfo| awk {'print $4'}| sed -e 's/\(^.*\)\(.$\)/\2/'` = "T" ] ||
		   [ `df $DstDir| tail -1| awk {'print $4'}` -gt $(($fSize / 1024)) ]; then
			SpaceEnough=1
		fi
	;;
	*)	if [ `echo $DstInfo| awk {'print $3'}| sed -e 's/\(^.*\)\(.$\)/\2/'` = "T" ] ||
		   [ `df $DstDir| tail -1| awk {'print $3'}` -gt $(($fSize / 1024)) ]; then
			SpaceEnough=1
		fi
	;;
	esac
}

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

ExitIF () {
	# if night-time and free space on flash is enough
	[ `date +%H` -le 08 ] && CheckSpaceOnSrc && [ "$SrcFreeSpace" -ge "$CfFreeSpaceIsEnough" ] && exit
}

ExitIF

for i in "$SrcDir"*.ts; do
  if [ -e "$i" ]; then
	echo "$i"
	fName=${i##*/}
	fName0=${fName%.ts}
	fSize=`ls -l "$i"| awk {'print $5'}`
	if [ ! $fSize = "0" ] && sleep 10 && [ $fSize = `ls -l "$i"| awk {'print $5'}` ]; then
		CheckSpaceOnDest
		if [ "$SpaceEnough" = "1" ]; then
			echo "cp $SrcDir$fName0"
			cp "$SrcDir$fName0"* "$DstDir"
			[ $fSize = `ls -l "$SrcDir$fName0".ts| awk {'print $5'}` ] && rm -f "$SrcDir$fName0"*
		fi
	fi
  fi
  ExitIF
done
Receivers: dm7080sstt; 2x dm8000sstt; dm7020s <-Diseq1x4(1.0)<-3x Diseq1x10(1.1)<-
Dishes:
1.8m + 42E;36E;28E;23E;19E;16E
1.6m + 13E;10/9E;5E;1W;8W
1.6m + 75E;85E
1.1m + 53/55E;60E
1.1m + 12W;18W;24W
1.0m + 15W;22W;30W
1.0m + 7E;4/5W
TVs: Philips 46pfl9707s; Philips 42pfl9703h

4

Dienstag, 1. Mai 2012, 14:53

You can use python to calculate the free disk space yourself:

Quellcode

1
2
3
4
#!/usr/bin/python
from os import statvfs
s = statvfs("/media/hdd")
print s.f_bsize * s.f_bavail