Run External Program Upon Completion Not Working #14549

Open
opened 2026-02-22 01:11:02 -05:00 by deekerman · 31 comments
Owner

Originally created by @Decoy256 on GitHub (Apr 27, 2023).

qBittorrent & operating system versions

qBittorrent: 4.5.2 (qbittorrent-nox)
OS: TrueNAS-13.0-U4 - qBittorrent is running inside a jail which is running FreeBSD version 13.2-RELEASE
Qt: 5.15.8
Libtorrent: 1.2.18.0
Boost: 1.81.0
OpenSSL: 1.1.1t-freebsd
zlib: 1.2.13

What is the problem?

I have searched through the forums here and elsewhere trying to solve this, but nothing seems to work.

I am running a simple command upon torrent completion: unrar x -r "%F"/*.rar "%F"/

This WAS working flawlessly for months, but suddenly it stopped working. I've even completely removed the entire jail and reinstalled, but the problem persists.

Looking at the log file, it indicates that it runs the command, but I think it's lying. I tried to test what might be the problem and so gave it another command to run upon completion: echo "test" > /config/debug.txt

Again, the log says it ran this command, but the file is not created. Why does it think that it's running the command, but producing nothing from even the simplest of commands?

I've seen that others have had issues with qBittorrent not running bash scripts upon completion, but I'm not running bash scripts, just a simple unrar command (or even a simple "echo" command apparently).

Steps to reproduce

  1. Setup qBittorrent to run any command upon torrent completion
  2. Complete a torrent
  3. Witness the sorrow

Additional context

No response

Log(s) & preferences file(s)

No response

Originally created by @Decoy256 on GitHub (Apr 27, 2023). ### qBittorrent & operating system versions qBittorrent: 4.5.2 (qbittorrent-nox) OS: TrueNAS-13.0-U4 - qBittorrent is running inside a jail which is running FreeBSD version 13.2-RELEASE Qt: 5.15.8 Libtorrent: 1.2.18.0 Boost: 1.81.0 OpenSSL: 1.1.1t-freebsd zlib: 1.2.13 ### What is the problem? I have searched through the forums here and elsewhere trying to solve this, but nothing seems to work. I am running a simple command upon torrent completion: unrar x -r "%F"/*.rar "%F"/ This WAS working flawlessly for months, but suddenly it stopped working. I've even completely removed the entire jail and reinstalled, but the problem persists. Looking at the log file, it indicates that it runs the command, but I think it's lying. I tried to test what might be the problem and so gave it another command to run upon completion: echo "test" > /config/debug.txt Again, the log says it ran this command, but the file is not created. Why does it think that it's running the command, but producing nothing from even the simplest of commands? I've seen that others have had issues with qBittorrent not running bash scripts upon completion, but I'm not running bash scripts, just a simple unrar command (or even a simple "echo" command apparently). ### Steps to reproduce 1. Setup qBittorrent to run any command upon torrent completion 2. Complete a torrent 3. Witness the sorrow ### Additional context _No response_ ### Log(s) & preferences file(s) _No response_
Author
Owner

@krmcleod02 commented on GitHub (Apr 27, 2023):

Same issue.

Running direct on Ubuntu 22.04 LTS. Was working fine under 4.3, upgraded a few days ago to 4.5.2 for the sake of upgrading, and both the unrar and 7z external scripts refuse to run.

@krmcleod02 commented on GitHub (Apr 27, 2023): Same issue. Running direct on Ubuntu 22.04 LTS. Was working fine under 4.3, upgraded a few days ago to 4.5.2 for the sake of upgrading, and both the unrar and 7z external scripts refuse to run.
Author
Owner

@glassez commented on GitHub (Apr 27, 2023):

Could you test it with full paths of running programs specified?

@glassez commented on GitHub (Apr 27, 2023): Could you test it with full paths of running programs specified?
Author
Owner

@Decoy256 commented on GitHub (Apr 28, 2023):

@glassez I could, but it doesn't even run "echo", so I'm not sure if that would change anything.

Also, I can run "unrar" from the command line without the full path.

And the qBittorrent logs show that it is running these commands, but to no effect.

@Decoy256 commented on GitHub (Apr 28, 2023): @glassez I could, but it doesn't even run "echo", so I'm not sure if that would change anything. Also, I can run "unrar" from the command line without the full path. And the qBittorrent logs show that it *is* running these commands, but to no effect.
Author
Owner

@Decoy256 commented on GitHub (Apr 28, 2023):

@krmcleod02 Have you checked out the qBittorrent logs to see if it thinks that it is running the commands?

@Decoy256 commented on GitHub (Apr 28, 2023): @krmcleod02 Have you checked out the qBittorrent logs to see if it thinks that it is running the commands?
Author
Owner

@glassez commented on GitHub (Apr 28, 2023):

And the qBittorrent logs show that it is running these commands, but to no effect.

It is because the log message is posted unconditionally:
github.com/qbittorrent/qBittorrent@9801cd0323/src/app/application.cpp (L518-L521)

@glassez commented on GitHub (Apr 28, 2023): > And the qBittorrent logs show that it _is_ running these commands, but to no effect. It is because the log message is posted unconditionally: https://github.com/qbittorrent/qBittorrent/blob/9801cd0323576cb0811fffbe7785c2aeca43515e/src/app/application.cpp#L518-L521
Author
Owner

@glassez commented on GitHub (Apr 28, 2023):

I could, but it doesn't even run "echo", so I'm not sure if that would change anything.

IIRC, "echo" is built-in command of shell and not an executable so it cannot be run by qBittorrent.

Also, I can run "unrar" from the command line without the full path.

So I want to first find out if the problem is just that PATH is not available to the running process.

@glassez commented on GitHub (Apr 28, 2023): > I could, but it doesn't even run "echo", so I'm not sure if that would change anything. IIRC, "echo" is built-in command of shell and not an executable so it cannot be run by qBittorrent. > Also, I can run "unrar" from the command line without the full path. So I want to first find out if the problem is just that PATH is not available to the running process.
Author
Owner

@Decoy256 commented on GitHub (Apr 28, 2023):

It is because the log message is posted unconditionally:

Well, that's dumb. Kind of a pointless "log" if it isn't logging what actually happens. Can we submit that as a bug?

@Decoy256 commented on GitHub (Apr 28, 2023): > It is because the log message is posted unconditionally: Well, that's dumb. Kind of a pointless "log" if it isn't logging what *actually* happens. Can we submit *that* as a bug?
Author
Owner

@glassez commented on GitHub (Apr 28, 2023):

Can we submit that as a bug?

Sure.

@glassez commented on GitHub (Apr 28, 2023): > Can we submit _that_ as a bug? Sure.
Author
Owner

@krmcleod02 commented on GitHub (Apr 28, 2023):

So the log is showing it runs it against every torrent that's downloaded, but it doesn't report whether or not it's complete. My configuration keeps In Progress torrents in one folder, and then moves them to another for Completed downloads.

This is what is coming up in the log:

(N) 2023-04-28T15:46:18 - Enqueued torrent move. Torrent: #TORRENT NAME#. Source: #TORRENT LOCATION#. Destination: #DESTINATION LOCATION#

(N) 2023-04-28T15:46:18 - Start moving torrent. Torrent: #TORRENT NAME#. Destination: #DESTINATION LOCATION#

(N) 2023-04-28T15:46:18 - Moved torrent successfully. Torrent: #TORRENT NAME#. Destination: #DESTINATION LOCATION#

(N) 2023-04-28T15:46:18 - Torrent download finished. Torrent: #TORRENT NAME#

(N) 2023-04-28T15:46:18 - Running external program. Torrent: #TORRENT NAME#. Command: "/usr/local/bin/unrar" x -ibck -inul "#DESTINATION LOCATION#/*.r*" "#UNPACK LOCATION#"

Redacted for my own peace of mind. However, it doesn't give a report that it completed the External command, just claims that it ran it. It is pointing against the post move location when it reports the Unrar command. It just doesn't unpack the file.

@krmcleod02 commented on GitHub (Apr 28, 2023): So the log is showing it runs it against every torrent that's downloaded, but it doesn't report whether or not it's complete. My configuration keeps In Progress torrents in one folder, and then moves them to another for Completed downloads. This is what is coming up in the log: (N) 2023-04-28T15:46:18 - Enqueued torrent move. Torrent: #TORRENT NAME#. Source: #TORRENT LOCATION#. Destination: #DESTINATION LOCATION# (N) 2023-04-28T15:46:18 - Start moving torrent. Torrent: #TORRENT NAME#. Destination: #DESTINATION LOCATION# (N) 2023-04-28T15:46:18 - Moved torrent successfully. Torrent: #TORRENT NAME#. Destination: #DESTINATION LOCATION# (N) 2023-04-28T15:46:18 - Torrent download finished. Torrent: #TORRENT NAME# (N) 2023-04-28T15:46:18 - Running external program. Torrent: #TORRENT NAME#. Command: `"/usr/local/bin/unrar" x -ibck -inul "#DESTINATION LOCATION#/*.r*" "#UNPACK LOCATION#"` Redacted for my own peace of mind. However, it doesn't give a report that it completed the External command, just claims that it ran it. It is pointing against the post move location when it reports the Unrar command. It just doesn't unpack the file.
Author
Owner

@Decoy256 commented on GitHub (Apr 28, 2023):

@glassez It looks like the log posted by @krmcleod02 indicates that he is feeding it the full path.

I can't recall, but I think I might have run across this (providing the full path) as a suggestion a while ago in another thread somewhere on the internet (I've been dealing with this issue for some time) and I tried giving it the full path, but to no avail.

@Decoy256 commented on GitHub (Apr 28, 2023): @glassez It looks like the log posted by @krmcleod02 indicates that he *is* feeding it the full path. I can't recall, but I think I might have run across this (providing the full path) as a suggestion a while ago in another thread somewhere on the internet (I've been dealing with this issue for some time) and I tried giving it the full path, but to no avail.
Author
Owner

@glassez commented on GitHub (Apr 29, 2023):

I did a couple of quick tests and I see that it really runs (even w/o full path specified). Maybe the problem is not that it does not start, but that it cannot do useful work for some reason (for example, because of incorrect parameters or something else). Could you run qBittorrent from the console/terminal to see the output of the program being run?

@glassez commented on GitHub (Apr 29, 2023): I did a couple of quick tests and I see that it really runs (even w/o full path specified). Maybe the problem is not that it does not start, but that it cannot do useful work for some reason (for example, because of incorrect parameters or something else). Could you run qBittorrent from the console/terminal to see the output of the program being run?
Author
Owner

@glassez commented on GitHub (Apr 29, 2023):

So the log is showing it runs it against every torrent that's downloaded, but it doesn't report whether or not it's complete.

Even with this patch applied it won't report the status of executed programs (only whether or not it is started successfully) since the external process is started as detached.

@glassez commented on GitHub (Apr 29, 2023): > So the log is showing it runs it against every torrent that's downloaded, but it doesn't report whether or not it's complete. Even with [this patch](https://github.com/qbittorrent/qBittorrent/pull/18901) applied it won't report the status of executed programs (only whether or not it is started successfully) since the external process is started as detached.
Author
Owner

@Decoy256 commented on GitHub (Apr 29, 2023):

@glassez I am not sure what you mean by "run qbittorrent". The service is running at startup.

@Decoy256 commented on GitHub (Apr 29, 2023): @glassez I am not sure what you mean by "run qbittorrent". The service is running at startup.
Author
Owner

@glassez commented on GitHub (Apr 29, 2023):

@glassez I am not sure what you mean by "run qbittorrent". The service is running at startup.

I mean start it manually, i.e. by typing the name of qBittorrent executable in shell command line. Just don't ask me how to do it in your system - I don't familiar with all these jails, etc.

@glassez commented on GitHub (Apr 29, 2023): > @glassez I am not sure what you mean by "run qbittorrent". The service is running at startup. I mean start it manually, i.e. by typing the name of qBittorrent executable in shell command line. Just don't ask me how to do it in your system - I don't familiar with all these jails, etc.
Author
Owner

@Decoy256 commented on GitHub (Apr 29, 2023):

If I just type "/usr/local/etc/rc.d/qbittorrent", it says:

Usage: /usr/local/etc/rc.d/qbittorrent [fast|force|one|quiet] (start|stop|restart|rcvar|enable|disable|delete|enabled|describe|extracommands|status|poll)

When I type "/usr/local/etc/rc.d/qbittorrent restart", it outputs:

Stopping qbittorrent.
Waiting for PIDS: 20673.
Starting qbittorrent.
@Decoy256 commented on GitHub (Apr 29, 2023): If I just type "/usr/local/etc/rc.d/qbittorrent", it says: ``` Usage: /usr/local/etc/rc.d/qbittorrent [fast|force|one|quiet] (start|stop|restart|rcvar|enable|disable|delete|enabled|describe|extracommands|status|poll) ``` When I type "/usr/local/etc/rc.d/qbittorrent restart", it outputs: ``` Stopping qbittorrent. Waiting for PIDS: 20673. Starting qbittorrent. ```
Author
Owner

@glassez commented on GitHub (Apr 29, 2023):

If I just type "/usr/local/etc/rc.d/qbittorrent"

"/usr/local/etc/rc.d/qbittorrent" isn't a qBittorrent itself. It looks like some script that manages qBittorrent to be used as a service. You could read it to see how it executes qBittorrent.
P.S. you still need to stop running service instance before start it manually.

@glassez commented on GitHub (Apr 29, 2023): > If I just type "/usr/local/etc/rc.d/qbittorrent" "/usr/local/etc/rc.d/qbittorrent" isn't a qBittorrent itself. It looks like some script that manages qBittorrent to be used as a service. You could read it to see how it executes qBittorrent. P.S. you still need to stop running service instance before start it manually.
Author
Owner

@Decoy256 commented on GitHub (Apr 29, 2023):

This is the contents of the script:

#!/bin/sh

# PROVIDE: qbittorrent
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable this service:
#
# qbittorrent_enable:	     Set to NO by default. Set it to YES to enable it.
# qbittorrent_conf_dir:	     Directory where qbittorrent configuration
#			     data is stored.
#			     Default: /var/db/qbittorrent/conf
# qbittorrent_download_dir:  Directory to store downloaded data.
#			     Default: /var/db/qbittorrent/Downloads
# qbittorrent_user:	     The user account transmission daemon runs as.
#			     Default is 'qbittorrent'
# qbittorrent_group:	     The group associated with username qbittorrent
#			     daemon runs as. Default is 'qbittorrent'
#

. /etc/rc.subr

name=qbittorrent
rcvar=qbittorrent_enable

load_rc_config $name

: ${qbittorrent_enable="NO"}
: ${qbittorrent_conf_dir="/var/db/qbittorrent/conf"}
: ${qbittorrent_download_dir="/var/db/qbittorrent/Downloads"}
: ${qbittorrent_user=qbittorrent}
: ${qbittorrent_group=qbittorrent}

command="/usr/local/bin/qbittorrent-nox"
command_args="--daemon"

qbittorrent_flags=" \
	${qbittorrent_conf_dir:+--profile=${qbittorrent_conf_dir}} \
	${qbittorrent_download_dir:+--save-path=${qbittorrent_download_dir}} \
	${qbittorrent_flags}"

run_rc_command $1
@Decoy256 commented on GitHub (Apr 29, 2023): This is the contents of the script: ``` #!/bin/sh # PROVIDE: qbittorrent # REQUIRE: DAEMON # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf to enable this service: # # qbittorrent_enable: Set to NO by default. Set it to YES to enable it. # qbittorrent_conf_dir: Directory where qbittorrent configuration # data is stored. # Default: /var/db/qbittorrent/conf # qbittorrent_download_dir: Directory to store downloaded data. # Default: /var/db/qbittorrent/Downloads # qbittorrent_user: The user account transmission daemon runs as. # Default is 'qbittorrent' # qbittorrent_group: The group associated with username qbittorrent # daemon runs as. Default is 'qbittorrent' # . /etc/rc.subr name=qbittorrent rcvar=qbittorrent_enable load_rc_config $name : ${qbittorrent_enable="NO"} : ${qbittorrent_conf_dir="/var/db/qbittorrent/conf"} : ${qbittorrent_download_dir="/var/db/qbittorrent/Downloads"} : ${qbittorrent_user=qbittorrent} : ${qbittorrent_group=qbittorrent} command="/usr/local/bin/qbittorrent-nox" command_args="--daemon" qbittorrent_flags=" \ ${qbittorrent_conf_dir:+--profile=${qbittorrent_conf_dir}} \ ${qbittorrent_download_dir:+--save-path=${qbittorrent_download_dir}} \ ${qbittorrent_flags}" run_rc_command $1 ```
Author
Owner

@Decoy256 commented on GitHub (Apr 29, 2023):

This is what happens when I run /usr/local/bin/qbittorrent-nox:

https://www.imgbly.com/ib/wLe2BWortD

@Decoy256 commented on GitHub (Apr 29, 2023): This is what happens when I run `/usr/local/bin/qbittorrent-nox`: https://www.imgbly.com/ib/wLe2BWortD
Author
Owner

@glassez commented on GitHub (Apr 29, 2023):

This is what happens when I run /usr/local/bin/qbittorrent-nox:

First of all you should stop currently running qBittorrent service (as I said above) to prevent conflicts of used ports etc.
Second is you should start qBittorrent using the same user/group and command line parameters (e.g. --profile, but except --daemon) as configured to be used by service instance (otherwise you starts it using another profile).

@glassez commented on GitHub (Apr 29, 2023): > This is what happens when I run `/usr/local/bin/qbittorrent-nox`: First of all you should stop currently running qBittorrent service (as I said above) to prevent conflicts of used ports etc. Second is you should start qBittorrent using the same user/group and command line parameters (e.g. `--profile`, but except `--daemon`) as configured to be used by service instance (otherwise you starts it using another profile).
Author
Owner

@Decoy256 commented on GitHub (Apr 29, 2023):

So, could I just edit the script above and comment out the line that says command_args="--daemon"?

@Decoy256 commented on GitHub (Apr 29, 2023): So, could I just edit the script above and comment out the line that says `command_args="--daemon"`?
Author
Owner

@glassez commented on GitHub (Apr 29, 2023):

So, could I just edit the script above and comment out the line that says command_args="--daemon"?

You could try... Nothing terrible will happen (the main thing is, don't forget to put everything back in its place later).
Sorry, I'm not a *nix guru to confidently answer such questions (I use Windows 99% of the time).

@glassez commented on GitHub (Apr 29, 2023): > So, could I just edit the script above and comment out the line that says `command_args="--daemon"`? You could try... Nothing terrible will happen (the main thing is, don't forget to put everything back in its place later). Sorry, I'm not a *nix guru to confidently answer such questions (I use Windows 99% of the time).
Author
Owner

@Decoy256 commented on GitHub (Apr 29, 2023):

If there is nothing else in that script that you think might cause problems, then I think I'll give that a try.

@Decoy256 commented on GitHub (Apr 29, 2023): If there is nothing else in that script that you think might cause problems, then I think I'll give that a try.
Author
Owner

@Decoy256 commented on GitHub (Apr 29, 2023):

OK, I commented it out and it seems to work, except when I stop the jail and then restart it, the TrueNAS UI hangs and doesn't register that it has finished starting the jail. That's OK, since I can just refresh the UI and I can still shell into the jail. I will test to see if this fixes the execute external program issue. If it does work, that show what? That qbittorrent isn't properly handling the fact that it is running as a daemon? What would be the solution from there?

@Decoy256 commented on GitHub (Apr 29, 2023): OK, I commented it out and it *seems* to work, except when I stop the jail and then restart it, the TrueNAS UI hangs and doesn't register that it has finished starting the jail. That's OK, since I can just refresh the UI and I can still shell into the jail. I will test to see if this fixes the execute external program issue. If it does work, that show what? That qbittorrent isn't properly handling the fact that it is running as a daemon? What would be the solution from there?
Author
Owner

@Decoy256 commented on GitHub (Apr 29, 2023):

OK, I got it running with a torrent set to download, then went out for the day. Came back and the torrent has been stalled the whole time. Reset the script back to the way it was and everything started up and ran. Still not executing commands on completion, though.

@Decoy256 commented on GitHub (Apr 29, 2023): OK, I got it running with a torrent set to download, then went out for the day. Came back and the torrent has been stalled the whole time. Reset the script back to the way it was and everything started up and ran. Still not executing commands on completion, though.
Author
Owner

@glassez commented on GitHub (Apr 30, 2023):

OK, I got it running with a torrent set to download, then went out for the day. Came back and the torrent has been stalled the whole time

Well, it could still be because you ran it through a rc script...
In fact, if you are ready to just test it without having to seed all your existing torrents, then you could run it manually with a clean profile (as you did earlier, but don't forget to stop the service instance first and then make sure your manually started instance is OK by looking at qBittorrent log) and add a single torrent for downloading.

@glassez commented on GitHub (Apr 30, 2023): > OK, I got it running with a torrent set to download, then went out for the day. Came back and the torrent has been stalled the whole time Well, it could still be because you ran it through a rc script... In fact, if you are ready to just test it without having to seed all your existing torrents, then you could run it manually with a clean profile (as you did earlier, but don't forget to stop the service instance first and then make sure your manually started instance is OK by looking at qBittorrent log) and add a single torrent for downloading.
Author
Owner

@glassez commented on GitHub (Apr 30, 2023):

@qbittorrent/bug-handlers, could someone help with troubleshooting this issue?

@glassez commented on GitHub (Apr 30, 2023): @qbittorrent/bug-handlers, could someone help with troubleshooting this issue?
Author
Owner

@glottisfaun0000 commented on GitHub (May 1, 2023):

i'm having this same issue with qb 4.5.2 on macOS with the same results as @Decoy256 including when running with the path, e.g. "/usr/bin/touch ~/hi.txt". shows in log, nothing happened in filesystem.

@glottisfaun0000 commented on GitHub (May 1, 2023): i'm having this same issue with qb 4.5.2 on macOS with the same results as @Decoy256 including when running with the path, e.g. "/usr/bin/touch ~/hi.txt". shows in log, nothing happened in filesystem.
Author
Owner

@glassez commented on GitHub (May 2, 2023):

e.g. "/usr/bin/touch ~/hi.txt"

Although ~ has a special meaning for many command line shells it is just a regular character and it is interpreted accordingly by other software. "touch /home/glassez/hi.txt" works well for me.

@glassez commented on GitHub (May 2, 2023): > e.g. "/usr/bin/touch ~/hi.txt" Although `~` has a special meaning for many command line shells it is just a regular character and it is interpreted accordingly by other software. "touch /home/glassez/hi.txt" works well for me.
Author
Owner

@krmcleod02 commented on GitHub (May 2, 2023):

Apparently in a recent update, unrar somehow moved locations to /usr/bin in my case. I still had a residual location of /usr/local/bin/unrar, but it did nothing. The PATH had been changed.

After updating my command, it's running fine. Sorry for the confusion.

@krmcleod02 commented on GitHub (May 2, 2023): Apparently in a recent update, unrar somehow moved locations to /usr/bin in my case. I still had a residual location of /usr/local/bin/unrar, but it did nothing. The PATH had been changed. After updating my command, it's running fine. Sorry for the confusion.
Author
Owner

@glottisfaun0000 commented on GitHub (May 3, 2023):

does running external program support piping?

such as,
echo "%N" | /opt/homebrew/bin/notify

@glottisfaun0000 commented on GitHub (May 3, 2023): does running external program support piping? such as, echo "%N" | /opt/homebrew/bin/notify
Author
Owner

@glassez commented on GitHub (May 4, 2023):

does running external program support piping?

such as, echo "%N" | /opt/homebrew/bin/notify

No. All it does is call the executable and pass everything else to it as parameters. If you need some features of shell, then you could call the shell (e.g. bash) and pass it the appropriate parameters.

@glassez commented on GitHub (May 4, 2023): > does running external program support piping? > > such as, echo "%N" | /opt/homebrew/bin/notify No. All it does is call the executable and pass everything else to it as parameters. If you need some features of shell, then you could call the shell (e.g. bash) and pass it the appropriate parameters.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/qBittorrent#14549
No description provided.