Xfce Forum

Sub domains
 

You are not logged in.

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

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

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,313

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 ---

Offline

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

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

Re: Disk/disc space warning script?

What would we do without you bud?

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

Offline

#4 2024-07-20 00:32:22

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

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

#5 2024-07-23 01:37:36

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

Re: Disk/disc space warning script?

Cheers him610. I wonder if that general principle still holds as drives have become larger?

My usage hasn't changed much - I add new music infrequently but it's still the same filesize per minute which means it's gotten relatively cheaper and less problematic to store compared to the drives themselves. Video has moved to streaming meaning no ongoing storage need. Pictures continue to add up, but they don't weigh much. Videogames are huge but all can be uninstalled when not in use, and I barely get the chance to play anyway. Office files are generally small, and compress well when not in use.

All this to say: my total drive usage % has crept up over the years, but with a bit of management I can defer any purchasing need for another couple of years at least. The issue for me is not cost, but faff: when I upgraded my PC a few years ago I inadvertently used cables from my older PSU on my newer PSU (same brand); due to undocumented internal wiring differences, when I turned on the machine, it insta-fried 3 HDDs & 1 SDD. Now I'm on 2 x 2tb NVME/M2s which need no cables, but when they're full, I've got a tech decision to make that I'd be quite happy to ignore for another 10 years!

Offline

Board footer

Powered by FluxBB