Pre-requisite
In order for the pop-up message to appear, you would need to install “libnotify-bin”.
Script
The script will check the free disk space in “/dev/sda1″. It will show a pop-up message for 30 seconds when the free space is below 100MB. If the free space is below 50MB, it will show a pop-up message for 5 minutes. You should modify these parameters to your own requirement.
Copy and paste the script below to a file called “checklowdisk”.
- Code:
#!/bin/sh
DISKSPACE=`df | grep "/dev/sda1" | awk '{ print $4 }'`
if [ "$DISKSPACE" -lt "51200" ] ; then
/usr/bin/notify-send -u critical -t 300000 \
'Check low disk' '/dev/sda1 is less than 50MB.'
exit
fi
if [ "$DISKSPACE" -lt "102400" ] ; then
/usr/bin/notify-send -u normal -t 30000 \
'Check low disk' '/dev/sda1 is less than 100MB.'
fi
Setting up the script
Make the script executable:
Change file ownership to root:
Move file to “/usr/bin”:
Set-up crontab
I chose to run the script hourly using crontab.
Edit crontab:
- Code:
crontab -e
Add this line in the editor:
- Code:
00 * * * * env DISPLAY=:0 /usr/bin/checklowdisk
Save and close the editor. The crontab is now configured, and the script will run at the hour.
thanx:Chewearn
to free up disk space more effectively click here
0 comments:
Post a Comment