home directory size monitoring script
newbie here. am doing script on monitoring my directory /home that if it gets greater or equal to 86, then it will prompt me overload, else its fine.
please help what's wrong with my script. thanks SIZE='df -h /home | /bin/awk '{ print $5 }' | grep -v Use% | sed '/%//'' if [ $SIZE >= "86" ]; then echo "overload" else echo "ok" fi Allan |
One obvious error is $SIZE > "86" which should be $SIZE -gt 86.
Another problem might be grep Use%, I would grep Use\%. In Linux everything appearing on top of the number keys is suspicious and might need to be escaped. Finally run you script with sh -x yourscript jlinkels |
Or use quotas, that's kind of what they're for.
|
Hi,
Following is the corrected code. Another error was that you used /%// instead of s/%// in sed . Code:
#!/bin/sh indiajoe |
Thanks a lot. that worked. :)
Quote:
|
do it with just awk. No need grep or sed
Code:
$ df /home | awk '$5+0>86{print "overload"}' |
Quote:
|
All times are GMT -5. The time now is 11:18 PM. |