Script millega monitoorida ketta mahu täituvust


You would like to receive an email alert when your disk space gets low. For this, perform a quick Google search for, say, “Send an Email Alert When Your Disk Space Gets Low”. Amongst the various result, you will see the one from Linux Jornal. Click the URL and you will see the bash script documented on the page.

Create a new text file using nano for the bash script:

$ nano

Copy and paste the contents from the URL:

CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')

if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
    mail -s 'Disk Space Alert' << EOF
Your root partition remaining free space is critically low. Used: $CURRENT%

Note: Please do not forget to replace with your e-mail address. Also, please remember that you can modify the subject line as well.

Press “CTRL+X” and confirm with “Y” in order to save and exit the file.

You have now created a small bash program called which you can name it as you like.

We need to continue with telling our operating system that this file is an executable.

Give the file executable permission using “chmod”:

$ chmod +x

You can try to run the file by executing it: ./

Given that we would like this small program to act like a system monitor, we will need to use the utility tool cron to schedule it to run at certain intervals.