You are not logged in.

Dear visitor, welcome to Dreamboard. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Friday, February 17th 2012, 9:03pm

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

Quoted

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

Quoted

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: 3x dm8000sstt; 2x dm7020s <-Diseq1x4(1.0)<-3x Diseq1x10(1.1)<-
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 + 12W;18W;24W
0.8m + 4/5W
1.1m + 53E;60E
1.0m + 75E
TVs: Philips 46pfl9707s; Philips 42pfl9703h

2

Wednesday, February 22nd 2012, 4:23pm

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'}
Danke für den Fisch

3

Wednesday, February 22nd 2012, 9:40pm

@Gutemine
TANKS for reply, but still wrong value returned

Source code

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

Source code

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

Source code

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

Source code

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: 3x dm8000sstt; 2x dm7020s <-Diseq1x4(1.0)<-3x Diseq1x10(1.1)<-
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 + 12W;18W;24W
0.8m + 4/5W
1.1m + 53E;60E
1.0m + 75E
TVs: Philips 46pfl9707s; Philips 42pfl9703h

4

Tuesday, May 1st 2012, 2:53pm

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

Source code

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