Need support with rclone service file

What is the problem you are having with rclone?

I want to run a service which automatically mounts my gdrive

What is your rclone version (output from rclone version)

v1.53.1

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

Debian 10

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)

I mount the gdrive with the following command:
rclone mount gdrive: /home/iragoiko/gdrive --allow-other --dir-cache-time 96h --vfs-cache-max-age 48h --vfs-read-chunk-size 20M --vfs-read-chunk-size-limit 1G --buffer-size 10M --umask 002 --log-file /home/iragoiko/rclone.log

Now I want to create a service, this is my rclone.service file:

Description=rclone

[Service]
User=iragoiko
ExecStart=/usr/bin/rclone mount gdrive: /home/iragoiko/gdrive --allow-other --dir-cache-time 96h --vfs-cache-max-age 48h --vfs-read-chunk-size 20M --vfs-read-chunk-size-limit 1G --buffer-size 10M --umask 002 --log-file /home/iragoiko/rclone.log
Restart=on-abort

[Install]
WantedBy=multi-user.target

The rclone config contents with secrets removed.

[gdrive]
type = drive
client_id = 4149693**********************************divuc.apps.googleuserconten$
client_secret = dMgoL1X***************NOlj4
scope = drive
token = {"access_token":"ya29.A0AfH6SM****************************************ezpSaY4Zx1t$

A log from the command with the -vv flag

root@debian:/etc/systemd/system# systemctl start rclone.service
Warning: The unit file, source configuration file or drop-ins of rclone.service changed on disk. Run 'systemctl daemon-reload' to reload units.
Job for rclone.service failed because the control process exited with error code.
See "systemctl status rclone.service" and "journalctl -xe" for details.

hi, did you do this?
systemctl daemon-reload

just did it.

 rclone.service - rclone
   Loaded: loaded (/etc/systemd/system/rclone.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-10-24 19:47:22 CEST; 1min 0s ago
  Process: 3047 ExecStart=/usr/bin/rclone rclone mount gdrive: /home/iragoiko/gdrive --allow-other --dir-cache-time 96h --vfs-cache-max-age
 Main PID: 3047 (code=exited, status=1/FAILURE)

oct 24 19:47:22 debian systemd[1]: Started rclone.
oct 24 19:47:22 debian rclone[3047]: Error: unknown command "rclone" for "rclone"
oct 24 19:47:22 debian rclone[3047]: Run 'rclone --help' for usage.
oct 24 19:47:22 debian rclone[3047]: 2020/10/24 19:47:22 Fatal error: unknown command "rclone" for "rclone"
oct 24 19:47:22 debian systemd[1]: rclone.service: Main process exited, code=exited, status=1/FAILURE
oct 24 19:47:22 debian systemd[1]: rclone.service: Failed with result 'exit-code'.

change
ExecStart=/usr/bin/rclone rclone mount
to
ExecStart=/usr/bin/rclone mount

now this is the output:

Warning: The unit file, source configuration file or drop-ins of rclone.service changed on disk. Run 'systemctl daemon-reload' to reload uni
● rclone.service - rclone
   Loaded: loaded (/etc/systemd/system/rclone.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-10-24 19:47:22 CEST; 6min ago
  Process: 3047 ExecStart=/usr/bin/rclone rclone mount gdrive: /home/iragoiko/gdrive --allow-other --dir-cache-time 96h --vfs-cache-max-age
 Main PID: 3047 (code=exited, status=1/FAILURE)

oct 24 19:47:22 debian systemd[1]: Started rclone.
oct 24 19:47:22 debian rclone[3047]: Error: unknown command "rclone" for "rclone"
oct 24 19:47:22 debian rclone[3047]: Run 'rclone --help' for usage.
oct 24 19:47:22 debian rclone[3047]: 2020/10/24 19:47:22 Fatal error: unknown command "rclone" for "rclone"
oct 24 19:47:22 debian systemd[1]: rclone.service: Main process exited, code=exited, status=1/FAILURE
oct 24 19:47:22 debian systemd[1]: rclone.service: Failed with result 'exit-code'.

as i suggested above
change
ExecStart=/usr/bin/rclone rclone mount
to
ExecStart=/usr/bin/rclone mount

sorry I forgot to run again.

rclone.service - rclone
   Loaded: loaded (/etc/systemd/system/rclone.service; disabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-10-24 19:57:55 CEST; 3s ago
 Main PID: 3588 (rclone)
    Tasks: 18 (limit: 19660)
   Memory: 26.9M
   CGroup: /system.slice/rclone.service
           └─3588 /usr/bin/rclone mount gdrive: /home/iragoiko/gdrive --allow-other --dir-cache-time 96h --vfs-cache-max-age 48h --vfs-read-

oct 24 19:57:55 debian systemd[1]: Started rclone.

Looks like it is working, thanks for your support @asdffdsa .
For my understanding, will this service mount at reboot automatically before plex docker is running?

glad to help.

i think you need to run this to get systemd to start a service at boot time.
sudo systemctl enable rclone.service

I type that command but after reboot this is the status:

● rclone.service - rclone
   Loaded: loaded (/etc/systemd/system/rclone.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-10-24 20:15:16 CEST; 29s ago
  Process: 792 ExecStart=/usr/bin/rclone mount gdrive: /home/iragoiko/gdrive --allow-other --dir-cache-time 96h --vfs-cache-max-age 48h --vfs-read-chunk-size 20M --vfs-read-chunk-size-limit 1G --
 Main PID: 792 (code=exited, status=1/FAILURE)

oct 24 20:15:16 debian systemd[1]: Started rclone.
oct 24 20:15:16 debian systemd[1]: rclone.service: Main process exited, code=exited, status=1/FAILURE
oct 24 20:15:16 debian systemd[1]: rclone.service: Failed with result 'exit-code'.

post the rclone.service file

All my setup is in the first post. See below rclone.service file

[Unit]
Description=rclone

[Service]
User=iragoiko
ExecStart=/usr/bin/rclone mount gdrive: /home/iragoiko/gdrive --allow-other --dir-cache-time 96h --vfs-cache-max-age 48h --vfs-read-chunk-size 20M --vfs-read-chunk-size-limit 1G --buffer-size 10M --umask 002 --log-file /home/iragoiko/rclone.log
Restart=on-abort

[Install]
WantedBy=multi-user.target

Thanks :slight_smile:

i know that i shared this link with you, in this post or the other post
this will explain what to do.
https://github.com/rclone/rclone/wiki/Systemd-rclone-mount

Thanks for your reply. I have set the following rclone.service

[Unit]
Description=RClone Service
Wants=network-online.target
After=network-online.target

[Service]
Type=notify
Environment=RCLONE_CONFIG=/home/iragoiko/.config/rclone.conf
ExecStart=/usr/bin/rclone mount gdrive: /home/iragoiko/gdrive \
# This is for allowing users other than the user running rclone access to the mount
--allow-other \
# Google Drive is a polling remote so this value can be set very high and any changes are detected via polling.
--dir-cache-time 96h \
# The log level output
--log-level INFO \
# Location of the log file
--log-file /home/iragoiko/rclone/rclone.log \
# I reduce the poll interval down to 15 seconds as this makes changes appear fast the API quotas per day are huge
--poll-interval 15s \
# This is setting the file permission on the mount to user and group have the same access and other can read
--umask 002 \
# The local disk used for caching
--cache-dir=/cache \
# This is used for caching files to local disk for streaming
--vfs-cache-mode full \
# This limits the cache size to the value below
--vfs-cache-max-size 30G \
# This limits the age in the cache if the size is reached and it removes the oldest files first
--vfs-cache-max-age 336h \
# This sets up the remote control daemon so you can issue rc commands locally
--rc \
ExecStop=/bin/fusermount -uz /home/iragoiko/gdrive
Restart=on-success
RestartSec=5

[Install]
WantedBy=multi-user.target

Y run the service and this is the status log

 rclone.service - RClone Service
   Loaded: loaded (/etc/systemd/system/rclone.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-10-24 22:37:38 CEST; 16s ago
  Process: 8507 ExecStart=/usr/bin/rclone mount gdrive: /home/iragoiko/gdrive --allow-other --dir-cache-time 96h --log-level INFO --log-file /home
 Main PID: 8507 (code=exited, status=1/FAILURE)

oct 24 22:37:38 debian rclone[8507]:       --vfs-write-wait duration                Time to wait for in-sequence write before giving error. (defau
oct 24 22:37:38 debian rclone[8507]:       --volname string                         Set the volume name (not supported by all OSes).
oct 24 22:37:38 debian rclone[8507]:       --write-back-cache                       Makes kernel buffer writes before sending them to rclone. With
oct 24 22:37:38 debian rclone[8507]: Use "rclone [command] --help" for more information about a command.
oct 24 22:37:38 debian systemd[1]: rclone.service: Main process exited, code=exited, status=1/FAILURE
oct 24 22:37:38 debian rclone[8507]: Use "rclone help flags" for to see the global flags.
oct 24 22:37:38 debian rclone[8507]: Use "rclone help backends" for a list of supported services.
oct 24 22:37:38 debian rclone[8507]: 2020/10/24 22:37:38 Fatal error: unknown shorthand flag: 'z' in -z
oct 24 22:37:38 debian systemd[1]: rclone.service: Failed with result 'exit-code'.
oct 24 22:37:38 debian systemd[1]: Failed to start RClone Service.

try
ExecStart=/usr/bin/rclone mount gdrive: /home/iragoiko/gdrive

Change applied. Log:

root@debian:/etc/systemd/system# systemctl status rclone.service
● rclone.service - RClone Service
   Loaded: loaded (/etc/systemd/system/rclone.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-10-24 22:51:00 CEST; 6s ago
  Process: 9209 ExecStart=/usr/bin/rclone mount gdrive: /home/iragoiko/gdrive (code=exited, status=1/FAILURE)
 Main PID: 9209 (code=exited, status=1/FAILURE)

oct 24 22:51:00 debian systemd[1]: Starting RClone Service...
oct 24 22:51:00 debian rclone[9209]: 2020/10/24 22:51:00 NOTICE: Config file "/home/iragoiko/.config/rclone.conf" not found - using defaults
oct 24 22:51:00 debian rclone[9209]: 2020/10/24 22:51:00 Failed to create file system for "gdrive:": didn't find section in config file
oct 24 22:51:00 debian systemd[1]: rclone.service: Main process exited, code=exited, status=1/FAILURE
oct 24 22:51:00 debian systemd[1]: rclone.service: Failed with result 'exit-code'.
oct 24 22:51:00 debian systemd[1]: Failed to start RClone Service.
root@debian:/etc/systemd/system#

If I run with my user

iragoiko@debian:~$ systemctl status rclone.service
● rclone.service - RClone Service
   Loaded: loaded (/etc/systemd/system/rclone.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-10-24 22:53:41 CEST; 15s ago
  Process: 9386 ExecStart=/usr/bin/rclone mount gdrive: /home/iragoiko/gdrive (code=exited, status=1/FAILURE)
 Main PID: 9386 (code=exited, status=1/FAILURE)
iragoiko@debian:~$

i thought you were using joy_drive:

What does it mean?

rclone cannot find that remote name of gdrive:
you must use a name from rclone listremotes

This is mi rclone config

[gdrive]
type = drive
client_id = 4149693**********************************divuc.apps.googleuserconten$
client_secret = dMgoL1X***************NOlj4
scope = drive
token = {"access_token":"ya29.A0AfH6SM****************************************ezpSaY4Zx1t$

Name is gdrive

My mount directory is

/home/iragoiko/gdrive