I am working on Sun Solaris 5.10 and want to direct the output from a disk space check script to an output file;
#!/bin/bash
CURRENT=$(df -k /log/logs | grep /log/logs | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=30
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
echo "Remaining free space is low" > output.txt
else
echo "Space seems ok" > output.txt
fi
It does not seem to be working with the first part and just displays 'space seems ok' while the current space is above the threshold. Any possible hints, indicators would be helpful. Thanks in advance.
Thanks, so it seems it does not work after "grep" as it shows below;
+ + df -k /log/logs
CURRENT=Filesystem kbytes used avail capacity Mounted on
/log 20643785 8189598 12247750 41% /log
+ + grep /log/logs
+ df -k /log/logs
CURRENT=
This is where it is getting a little confusing, used the same script on another server and it works but instead of directing output to a file it emails instead;