Systemd unit file for rclone `inactive (dead)` at boot

What is the problem you are having with rclone?

My rclone systemctl unit works if I start it manually but doesn't come up at boot.

What is your rclone version (output from rclone version)

$ rclone --version
rclone v1.55.1
- os/type: linux
- os/arch: amd64
- go/version: go1.16.3
- go/linking: static
- go/tags: none

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Ubuntu 20.10

Which cloud storage system are you using? (eg Google Drive)

MS OneDrive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone mount (via systemctl, see below)

The rclone config contents with secrets removed.

[onedrive]
type = onedrive
region = global
token = REDACTED
drive_id = REDACTED
drive_type = business

A log from the command with the -vv flag

There's nothing in the log file since the last reboot

More info

I've installed the unit in --user mode with

systemctl --user enable rclone.service
systemctl --user start rclone.service

After reboot, it's inactive (dead):

$ systemctl --user status rclone.service 
● rclone.service - RClone Service
     Loaded: loaded (/etc/xdg/systemd/user/rclone.service; enabled; vend>
     Active: inactive (dead)

Here's the unit file:

$ systemctl --user cat rclone.service 
# /etc/xdg/systemd/user/rclone.service
[Unit]
Description=RClone Service
Wants=network-online.target
After=network-online.target

[Service]
Type=notify
Restart=on-abort
RestartSec=5
KillMode=none

ExecStart=/usr/bin/rclone \
  mount onedrive: \
  /mnt/onedrive \
  --config /home/tom/.config/rclone/rclone.conf \
  --log-file /var/log/rclone/rclone.log \
  --log-level INFO \
  --vfs-cache-mode full \
  --cache-dir /home/tom/.cache/rclone/onedrive

ExecStop=/bin/fusermount -u -z \
  /mnt/onedrive

[Install]
WantedBy=multi-user.target

There's nothing in the log file since the last reboot. network-online.target is active:

$ systemctl status network-online.target
● network-online.target - Network is Online
     Loaded: loaded (/lib/systemd/system/network-online.target; static)
     Active: active since Wed 2021-06-02 08:33:02 AEST; 1h 41min ago
       Docs: man:systemd.special(7)
             https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget

Jun 02 08:33:02 tom systemd[1]: Reached target Network is Online.

And running systemctl --user start rclone.service brings the mount up.

There's a similar closed issue called "Systemctl service starts manually, but not on boot" (seems I'm not permitted to link to it, sorry). The fix in that thread was to disable and re-enable the service, which I've tried. The problem still exists after reboot.

There are some other systemd issues on the forum that seem to have been caused by windows line endings. That's not the case here, I wrote the file on a linux machine and checked the encoding.

I would appreciate any further suggestions because I'm not sure how to troubleshoot this. In particular I'm not sure if these lines are correct:

Type=notify
Restart=on-abort
KillMode=none

Thanks for reading!

hello and welcome to the forum,

best to use these settings from @Animosity022
https://github.com/animosity22/homescripts/blob/master/systemd/rclone.service

1 Like

Thanks for the suggestion. The only difference I can see (apart from running the remote control daemon) is that unit uses Restart=on-failure.

I changed my unit file from Restart=on-abort to Restart=on-failure, reloaded (disable / enable) and rebooted and it still didn't start.

sorry, not too knowledgeable about systemd.

hopefully, @Animosity022 or someone else will stop by soon.....

1 Like

Can you share the output of:

systemctl --user disable rclone.service
systemctl --user enable rclone.service
1 Like
$ systemctl --user disable rclone.service
Removed /home/tom/.config/systemd/user/multi-user.target.wants/rclone.service.

$ systemctl --user enable rclone.service
Created symlink /home/tom/.config/systemd/user/multi-user.target.wants/rclone.service → /etc/xdg/systemd/user/rclone.service.

Oh I think I see.

You are running as a user.

I think should be:

WantedBy=default.target

I normally don't run as user as I have root on my server.

And if you run this, you should see "green dots" over "red dots".

image

As an example.

systemctl --user list-dependencies
1 Like

Thanks very much for the help!

Fixed with:

WantedBy=default.target

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.