script question in VM

vikozo

Renowned Member
May 4, 2014
781
30
93
suisse
www.wombat.ch
Hallo
also direkt mit Proxmox hat es nicht zu tun, um eine hilfe trotzdem froh.
in einem VM habe ich jellyfin installiert und sehe damit Filme. soweit klappt es auch!
Bloss füllt sich die Festplatte mit *.ts file bis 100% voll und dann stürtz das Programm ab.

Code:
#!/bin/bash

Limit=50
usedSpaceProzent=$(df -h /dev/sda1 | awk '/[0-9]+%/{ gsub("%","");print $5}')

if [ Limit -lt  usedSpaceProzent  ]
then
 
echo "then -->  Limit = $Limit | usedSpace = $usedSpaceProzent "
sleep 1m
checkspace.sh

else

cd /
cd /var/lib/jellyfin/transcodes/
rm *.ts
echo "else -->  Limit = $Limit | usedSpace = $usedSpaceProzent "

sleep 1m
checkspace.sh
fi

Das Problem scheint das if [ ] zu sein!

Wenn unter 50 sollte die then info kommen über 50 sollte im verzeichnis die *.ts gelöscht werden
error bekomme ich ein
/usr/local/bin/checkspace.sh: Zeile 6: [: Limit: Ganzzahliger Ausdruck erwartet.

wobei das else doch ausgeführt wird das heisst immer ausgeführt wird.

hoffe auf eine hilfe um den script besser zu machen

vielen Dank
vinc
 
erstes Problem gelöst wenn ich das if in [[ ]] setze läuft es korrekt
wäre jetzt noch gut den Befehl zu finden um

die neusten 5 TS file zu behalten oder die älteren als 1 oder 2 minuten zu löschen
 
zurzeit habe ich
Code:
find /var/lib/jellyfin/transcodes/ -name "*.ts" -type f -ctime -0.9  -delete
aber funktioniert nicht wie gewünscht - löscht zuviel
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!