Systemd service for rclone mounts/docker autostart

What is the problem you are having with rclone?

Hello. I have three custom systemd services, two rclone mount services and one for starting my docker stack. At the moment I have disabled autostart on these services because I have an annoying problem on my server where unbound fails to autostart when I reboot and I have to manually start it. Without unbound the server has no internet access so the mounts won't start either. I think it's due to timing of the autostart or something because it starts without a problem with systemctl start.

What I would like to do is have one "master" service that starts the other services provided that they meet the criteria for starting. Any help on approaching this would be much appreciated.

Another annoying error I have when rebooting the server is that sonarr/radarr can't see the rclone mount the first time they are started. First I start the rclone mount service, then I start my docker compose service. Now I need to restart radarr/sonarr one time in order for them to see the root folders (rclone mount).

Basically I would like some help with creating a systemd service that does the following:

  1. Wait for a while to let other system services start up
  2. Start unbound
  3. If unbound started successfully and the server has internet access, start mount service 1
    and mount service 2
  4. Wait until the mounts are available in the file system (no idea how to do this check in the service)
  5. Start docker compose service.

I am running Ubuntu 22.04

Run the command 'rclone version' and share the full output of the command.

rclone v1.61.1

  • os/version: ubuntu 22.04 (64 bit)
  • os/kernel: 5.19.0-45-generic (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.19.4
  • go/linking: static
  • go/tags: none

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

Google Drive

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

Here are my 3 systemd services:

rclone-drive.service (used to start my main mount:

Description=RClone Service

ExecStart=/usr/bin/rclone mount \
  --config=/opt/rclone/rclone.conf \
  --log-level=INFO \
  --bwlimit 25M:off \
  --log-file=/opt/rclone/logs/rclone-mount.log \
  --umask=002 \
  --gid=1000 \
  --uid=1000 \
  --allow-other \
  --timeout=1h \
  --poll-interval=15s \
  --dir-cache-time=1000h \
  --cache-dir=/media/ssd/rclone_cache \
  --vfs-cache-mode=full \
  --vfs-cache-max-size=1500G \
  --vfs-cache-max-age=12h \
  --vfs-read-ahead=2G \
  gcrypt_direct: /data1/Allt
ExecStop=/bin/fusermount -uz /data1/Allt


rclone-drive-nextcloud.service (used to start a separate mount for seafile (haven't bothered to change the service name:

Description=RClone Service Nextcloud

#ExecStart=/usr/bin/rclone mount gcrypt_direct: /data1/Allt --log-file /opt/rclone/logs/gcrypt_direct.log --allow-other
#ExecStop=/bin/fusermount -uz /data1/Allt
ExecStart=/usr/bin/rclone mount \
  --config=/opt/rclone/rclone.conf \
  --log-level=INFO \
  --log-file=/opt/rclone/logs/rclone-mount-seafile.log \
  --umask=002 \
  --gid=8000 \
  --uid=8000 \
  --allow-other \
  --timeout=1h \
  --poll-interval=15s \
  --dir-cache-time=1000h \
  --cache-dir=/media/ssd/rclone_cache_seafile \
  --vfs-cache-mode=full \
  --vfs-cache-max-size=100G \
  --vfs-cache-max-age=12h \
  gcrypt_nextcloud: /data2/seafile_data
ExecStop=/bin/fusermount -uz /data2/seafile_data


docker-compose.service, for starting my docker stack:

Description=Docker Compose container starter


#ExecStartPre=/usr/local/bin/docker-compose pull --quiet --parallel
ExecStart=docker-compose -f /opt/docker/docker-compose.yml up --detach

ExecStop=docker-compose -f /opt/docker/docker-compose.yml down

#ExecReload=/usr/local/bin/docker-compose pull --quiet --parallel
ExecReload=docker-compose -f /opt/docker/docker-compose.yml up --detach


The rclone config contents with secrets removed.

type = drive
token = 
root_folder_id = 
client_id = 
client_secret = 
team_drive = 

type = crypt
remote = gdrive:/gdrive/crypt
filename_encryption = obfuscate
directory_name_encryption = true
password = 
password2 = 

type = seafile
url = 
user =
pass =
2fa = true
auth_token = 

A log from the command with the -vv flag

Paste  log here

For this there are two options IMHO:

add to unbound.service

ExecStartPre=/bin/sleep 60

create an unbound.timer systemd to control unbound.service


make sure that unbound.service is disabled and timer is enabled - unbound.service it will be started by timer

in your mount services add:


and you can use systemd-networkd-wait-online.service to check for internet connection



and write simple script checking and waiting until mount is ready

Thanks. For the timer service how would I start the unbound service? Via "systemctl start unbound" or should I copy the original unbound.service?

timer is bound to service by name

unbound.timer starts unbound.service when it fires

You do not change anything in unbound.service - do not forget to disable it - otherwise systemd will start it regardless of timer or not

this is all what is needed in timer:


Here more details:

Ah I see. And the unbound.timer should be in /lib/systemd/system or /etc/systemd/system?

The same folder where service is seems logical.

Thanks, I will try your suggestions!

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