Skip to content

Incorrect code in "Stop if disk is full" Docker code? #196

@Sabb0

Description

@Sabb0

Hi all,

I was setting this up and had to change the code for docker to get it to work.

https://autobrr.com/usage/tips#create-the-script

#!/bin/sh
set -e

reqSpace=250000000 # 250GB
SPACE=$(df "/torrents" | awk 'END{print $4}')
if [ "$SPACE" -le $reqSpace ]
then
  echo "not enough space"
  echo "free $SPACE"
  exit 1
fi
echo "got space"
echo "free $SPACE"
exit 0

The {print $4} was displaying the % free of the disk, and not the byte free. I changed it to {print $3} and it worked.


#!/bin/sh
set -e

reqSpace=250000000 # 250GB
SPACE=$(df "/torrents" | awk 'END{print $3}')
if [ "$SPACE" -le $reqSpace ]
then
  echo "not enough space"
  echo "free $SPACE"
  exit 1
fi
echo "got space"
echo "free $SPACE"
exit 0

Not sure if this has been picked up before, or if it's unique to my system.... I'm new when it comes to looking at code!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions