Xfce Forum

Sub domains
 

You are not logged in.

#1 2024-07-05 18:05:59

Sharky
Member
Registered: 2014-08-16
Posts: 50

Disk/disc space warning script?

Hi folks,

A few times I've unexpectedly completely exhausted the space on my primary drive. In fairness, the system has been great: hasn't spectacularly crashed or whatever. But I'd like to avoid this happening without me having any warning.

This answer is promising but defunct. Is there any package, existing setting, or simple script I could run to do this?

I'm happy to try to do something in bash & cron - notwithstanding a general poor ability - but I wanted to check whether something already exists 'off the shelf' as it were.

Cheers y'all!

Offline

#2 2024-07-06 00:08:42

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,237

Re: Disk/disc space warning script?

There is the xfce4-fsguard-plugin that can alert you when usage limits are reached. You can place multiple instances of these on the panel.

Alternatively, if you're looking for a script to run:

#!/usr/bin/env bash
 
# Used Space Trigger - at what % of used space do you want to be notified
USTRIGGER=90
 
# the partition you want to monitor
PART=/dev/mmcblk1p2
 
# the amount of time between checks in seconds
CHECK=60
 
# don't run script if already running
if [ $(ps -ef | grep $0 | grep -v grep | wc -l) -gt 2 ]; then 
	exit 1 
fi
 
while true
do
    USEDSPACE=$(df -h | grep "$PART" | awk '{print $5}' | tr -d '%')
 
    if [ $USEDSPACE -ge $USTRIGGER ]; then
        notify-send -i disk-quota-low "Low Space Warning" "You have allocated $USEDSPACE% of disk space on $PART"
    fi
 
    sleep $CHECK
done 

exit 0

....adjust the first 3 variables in the script to suit.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Online

#3 2024-07-06 06:25:00

Sharky
Member
Registered: 2014-08-16
Posts: 50

Re: Disk/disc space warning script?

What would we do without you bud?

Thanks, as always, and have a cracking weekend. Cheers!

Offline

#4 Yesterday 00:32:22

him610
Member
From: Pennsylvania USA
Registered: 2022-02-19
Posts: 15

Re: Disk/disc space warning script?

Several years ago, I worked with a hardware engineer whose advice was to never allow your disk to exceed 70% capacity. If it did, it was time to get a larger disk. smile


Do no harm.

Offline

Board footer

Powered by FluxBB