Jump to content

Systemd service timing out/restarting every few minutes even though service runs successfully

Go to solution Solved by AyaanMAG,

The issue was the whole config file a new config file not using the "forking" type made it work 

I have a Raspberry Pi 5 8gb running Raspberry Pi OS and the issue I'm having is that qbittorrent-nox, that i installed using apt keeps crashing after around 1 minute and 30 Seconds, since i have a service that starts qbittorrent-nox automatically, it starts back up within 3 secs, but the restarts are annoying and obviously bad for seeding and leeching and i was wondering why this is happening, experimenting a bit, in the logs something suggested that the systemd service is timing out, and sure enough su-ing to qbit the user for i made to run qbittorrent-nox seems to be running fine with no restarting, the logs and the systemd service file has been included before, i used boilerplate code and didn't do much tweaking and do not understand a lot of this either. Thank you for your help.

 

Service:

[Unit]
Description=qBittorrent Command Line Client
After=network.target

[Service]
#Do not change to "simple"
Type=forking
User=qbit
Group=qbit
ExecStart=/usr/bin/qbittorrent-nox
ExecStop=/usr/bin/killall -w qbittorrent-nox
Restart=on-failure

[Install]                                                                                                                                       
WantedBy=multi-user.target

 

Service Logs:

MAGPi@raspberrypi:~ $ journalctl -xeu qbit.service
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit qbit.service has finished with a failure.
░░
░░ The job identifier is 152795 and the job result is failed.
Dec 18 00:05:26 raspberrypi systemd[1]: qbit.service: Consumed 1.685s CPU time.
░░ Subject: Resources consumed by unit runtime
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit qbit.service has finished with a failure.
░░
░░ Defined-By: systemd
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A start job for unit qbit.service has finished with a failure.
░░ 
░░ The job identifier is 152795 and the job result is failed.
Dec 18 00:05:26 raspberrypi systemd[1]: qbit.service: Consumed 1.685s CPU time.
░░ Subject: Resources consumed by unit runtime
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ The unit qbit.service completed and consumed the indicated resources.
Dec 18 00:05:26 raspberrypi systemd[1]: qbit.service: Scheduled restart job, restart counter is at 1784.
░░ Subject: Automatic restarting of a unit has been scheduled
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ Automatic restarting of the unit qbit.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Dec 18 00:05:26 raspberrypi systemd[1]: Stopped qbit.service - qBittorrent Command Line Client.
░░ Subject: A stop job for unit qbit.service has finished
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A stop job for unit qbit.service has finished.
░░ 
░░ The job identifier is 152877 and the job result is done.
Dec 18 00:05:26 raspberrypi systemd[1]: qbit.service: Consumed 1.685s CPU time.
░░ Subject: Resources consumed by unit runtime
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ The unit qbit.service completed and consumed the indicated resources.
Dec 18 00:05:26 raspberrypi systemd[1]: Starting qbit.service - qBittorrent Command Line Client...
░░ Subject: A start job for unit qbit.service has begun execution
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A start job for unit qbit.service has begun execution.
░░ 
░░ The job identifier is 152877.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Are you maxing out your CPU, Memory, etc?

Have you tried reinstalling the application?

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, josefah said:

Also try changing the log level for the service to give you more details. 

 

Step 1: Open the Service File

  • Locate the systemd service file for qbittorrent-nox. This file is usually located in /etc/systemd/system/ and would be named something like qbit.service based on your description.
  • Open the file with a text editor. You might need superuser privileges to do this. For example, use sudo nano /etc/systemd/system/qbit.service.

Step 2: Modify the Service File to Increase Log Verbosity

  • Under the [Service] section of the file, add a new line: Environment=SYSTEMD_LOG_LEVEL=debug.

  • This line sets an environment variable SYSTEMD_LOG_LEVEL to debug for the service. The debug level is one of the most verbose and will provide detailed logs about the service's operation.

  • Here's what the modified section might look like:

    [Service]
    Type=forking
    User=qbit
    Group=qbit
    ExecStart=/usr/bin/qbittorrent-nox
    ExecStop=/usr/bin/killall -w qbittorrent-nox
    Restart=on-failure
    Environment=SYSTEMD_LOG_LEVEL=debug
    

     

Step 3: Reload Systemd Daemon

  • After saving the changes to the service file, you need to reload the systemd daemon to apply these changes.
  •  
  • Use the command:
sudo systemctl daemon-reload.

Step 4: Restart the Service

  • Restart the qbittorrent-nox service to apply the changes and start generating more detailed logs. Use the command:
sudo systemctl restart qbit.service.

Step 5: Analyze the Logs

  • After the service has been running for a while (or after it crashes again), check the logs using journalctl.
  • To view the logs specifically for your service, use:
journalctl -u qbit.service.
  • With the debug log level, you should see more detailed information which can help in diagnosing the issue.

Step 6: Revert the Changes (Optional)

  • Once you've diagnosed and resolved the issue, you might want to revert the log level to its default to prevent the logs from becoming too verbose.
  • Simply remove or comment out the Environment=SYSTEMD_LOG_LEVEL=debug line in the service file, then reload and restart as before.

Important Notes:

  • Increasing log verbosity can result in very large log files, especially for services that run continuously. Monitor your disk space usage if you keep this setting for an extended period.
  • Detailed logs can sometimes include sensitive information. Be cautious about where and how you share these logs.

This process should help you get a more detailed understanding of why qbittorrent-nox is failing when run as a systemd service.

Im not maxing any of my system resources out and 

journalctl -u qbit.service gives me only of significance:


Dec 16 03:01:30 raspberrypi qbittorrent-nox[51369]: QtLockedFile::lock(): file is not opened
Link to comment
Share on other sites

Link to post
Share on other sites

28 minutes ago, AyaanMAG said:

i used boilerplate code and didn't do much tweaking and do not understand a lot of this either.

What guide you using for setup the service? Guides I found for raspberrybi are setting a umask and running qbittorrent-nox as a deamon (-d flag)

make sure you are creating the user and group qbit

https://feriman.com/install-qbittorrent-on-raspberry-pi/

Link to comment
Share on other sites

Link to post
Share on other sites

18 minutes ago, C2dan88 said:

What guide you using for setup the service? Guides I found for raspberrybi are setting a umask and running qbittorrent-nox as a deamon (-d flag)

make sure you are creating the user and group qbit

https://feriman.com/install-qbittorrent-on-raspberry-pi/

I'll be honest i have no idea anymore, but this worked well but i also found 

Dec 16 03:01:30 raspberrypi qbittorrent-nox[51369]: QtLockedFile::lock(): file is not opened

 

Link to comment
Share on other sites

Link to post
Share on other sites

8 hours ago, AyaanMAG said:

Im not maxing any of my system resources out and 

journalctl -u qbit.service gives me only of significance:


Dec 16 03:01:30 raspberrypi qbittorrent-nox[51369]: QtLockedFile::lock(): file is not opened


A locked file can be related to multiple processes trying to access the file at the same time so it will close one of them. 

It can, at times be reinstalled to fix the issue, a patch, or, being linux there could be a specific way that it needs to be installed to prevent this. 

This command will search your core dump for mentions of qbittorrent. 
coredumpctl list | grep qbittorrent


Here is a thread with this exact issue. it's old but will hopefully get you pointed in the right direction. 
[SOLVED] QtLockedFile::lock(): file is not opened in Debian-7 ARM - qBittorrent official forums

This looks to be the link to the solution. 
http://unix.stackexchange.com/questions ... -recursive
 

Link to comment
Share on other sites

Link to post
Share on other sites

The issue was the whole config file a new config file not using the "forking" type made it work 

Link to comment
Share on other sites

Link to post
Share on other sites

14 hours ago, AyaanMAG said:

The issue was the whole config file a new config file not using the "forking" type made it work 

Makes sense so it won't create subprocesses from the parent. Glad you got it working. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×