Shutdown Qbittorrent when disk space is low? Script possibly?

Linux specific questions, problems.
Post Reply
bjames88

Shutdown Qbittorrent when disk space is low? Script possibly?

Post by bjames88 »

Hey I'm looking for a way to auto shutdown Qbittorrent when the drive gets low on space before it runs out.  I've been looking around by haven't found anything.  I'm thinking it should simple be a script?  A cron job maybe that checks and kill QB if the drive is getting low on space.  I was hoping for something that can gracefully shutdown QB so I don't corrupt any of my current running torrents in the process.

Thanks
User avatar
Nemo
Administrator
Administrator
Posts: 1744
Joined: Sat Jul 24, 2010 6:24 pm

Re: Shutdown Qbittorrent when disk space is low? Script possibly?

Post by Nemo »

I think that observing your HDD yourself and only downloading when you have enough space is a better way than to kill qBittorrent and (probably) corrupt your torrents.

Still, im not using Linux so if there is a script maybe someone else can respond to this.
snakyjake

Re: Shutdown Qbittorrent when disk space is low? Script possibly?

Post by snakyjake »

A better idea would be to pause all downloads.
I just had QBT crash because all the storage space was used up.  I also lost the payload of whatever I was downloading...probably over 20 GB lost.
ciaobaby

Re: Shutdown Qbittorrent when disk space is low? Script possibly?

Post by ciaobaby »

Until libtorrent supports arbitrary drive space checking and pausing, it's probably not going to happen.
bjames88

Re: Shutdown Qbittorrent when disk space is low? Script possibly?

Post by bjames88 »

Is there a command line command that I can use to exit QB?  If there is I should be able to write a bash script to accomplish this pretty easily.
ciaobaby

Re: Shutdown Qbittorrent when disk space is low? Script possibly?

Post by ciaobaby »

Just like you would stop any other process using the process name, send it a SIGTERM signal.

Code: Select all

killall qbittorrent 
will trigger a 'clean' shutdown

or

Code: Select all

killall qbittorrent -s SIGKILL
To just stop qbittorrent, this, however may leave some or all of the active tasks in a 'dirty' state, which will probably require a 'recheck' at next start up.
snakyjake

Re: Shutdown Qbittorrent when disk space is low? Script possibly?

Post by snakyjake »

[quote="bjames88"]
Is there a command line command that I can use to exit QB?  If there is I should be able to write a bash script to accomplish this pretty easily.
[/quote]

I am interested in your bash script.
snakyjake

Re: Shutdown Qbittorrent when disk space is low? Script possibly?

Post by snakyjake »

Another option would be to look into folder quotas or partitions.
My main problem with partitions is they don't seem to be flexible, or I don't know enough.
I'd like the option to shrink/expand quotas/partitons...without risk to screwing something up.
ciaobaby

Re: Shutdown Qbittorrent when disk space is low? Script possibly?

Post by ciaobaby »

[quote="snakyjake"]
[quote="bjames88"]
Is there a command line command that I can use to exit QB?  If there is I should be able to write a bash script to accomplish this pretty easily.
[/quote]

I am interested in your bash script.
[/quote]

Allow me to get you started :)

Code: Select all

#! /bin/bash
declare -i REQUIRED
REQUIRED=10*1024*1024*1024
# set minimum space required (GB) and convert to bytes

FREESPC=`df | grep sda1 | awk '{print $4}'`
# get free drive space in Bytes
if (( $FREESPC < $REQUIRED)); then
  echo "No Chance"
else 
  echo "No Problem "
fi

Replace 'sda1' with your drive device name, set your minimum space (in GB) and run the script in a crontab.
bjames88

Re: Shutdown Qbittorrent when disk space is low? Script possibly?

Post by bjames88 »

Yes that script is pretty much what I was going to do.  You got with the "dirty state" problem though.  Exactly what I was hoping to avoid with a proper shutdown.  Is there a setting to auto force check all incomplete torrents at every time Qbittorrent tarts?
ciaobaby

Re: Shutdown Qbittorrent when disk space is low? Script possibly?

Post by ciaobaby »

As I said,

Send a SIGTERM (-15) rather than a SIGKILL (-9) and wait for all processes to stop before shutting the machine down, if that is what you are doing.
bjames88

Re: Shutdown Qbittorrent when disk space is low? Script possibly?

Post by bjames88 »

OK thought you were saying that I would still get dirty torrent shutdowns even using the SIGTERM.  I guess I'll just have to give it a try and see what happens.  Thanks.
Post Reply