Rclone mount doesnt work as a systemd service

What is the problem you are having with rclone?

i am just trying to setup rclone mount command as systemd service so that it executes on every boot and i dont have to do it manaully
i used the service file template from here - https://github.com/animosity22/homescripts/blob/master/systemd/rclone.service

sudo nano /etc/systemd/system/rclone.service is having the following content

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

[Service]
Type=notify
Environment=RCLONE_CONFIG=/opt/rclone/rclone.conf
KillMode=none
RestartSec=5
ExecStart=/usr/bin/rclone mount test: /GD \
--allow-other \
--dir-cache-time 1000h \ 
--log-level INFO \
--log-file /opt/rclone/logs/rclone.log \
--poll-interval 15s \
--umask 002 \
--rc \
--rc-addr :5572 \
--rc-no-auth \
--cache-dir=/cache \
--vfs-cache-mode full 
ExecStop=/bin/fusermount -uz /GD
ExecStartPost=/usr/bin/rclone rc vfs/refresh recursive=true --rc-addr 127.0.0.1:5572 _async=true
Restart=on-failure
User=xd003
Group=xd003

[Install]
WantedBy=multi-user.target

Running sudo systemctl start rclone.service returns the following :

Job for rclone.service failed because the control process exited with error code.
See "systemctl status rclone.service" and "journalctl -xe" for details.
❯ systemctl status rclone.service
● rclone.service - RClone Service
     Loaded: loaded (/etc/systemd/system/rclone.service; disabled; vendor preset: disabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2020-09-25 18:21:43 IST; 3s ago
    Process: 23570 ExecStart=/usr/bin/rclone mount test: /GD --allow-other --dir-cache-time 1000h \ (code=exited, status=1/FAILURE)
   Main PID: 23570 (code=exited, status=1/FAILURE)

Sep 25 18:21:43 localhost systemd[1]: rclone.service: Main process exited, code=exited, status=1/FAILURE
Sep 25 18:21:43 localhost systemd[1]: rclone.service: Failed with result 'exit-code'.
Sep 25 18:21:43 localhost systemd[1]: Failed to start RClone Service.


❯ journalctl -xe
Sep 25 18:22:46 localhost rclone[23660]:       --vfs-case-insensitive                   If a file name not found, find a case insensitive match.
Sep 25 18:22:46 localhost rclone[23660]:       --vfs-read-ahead SizeSuffix              Extra read ahead over --buffer-size when using cache-mode full.
Sep 25 18:22:46 localhost rclone[23660]:       --vfs-read-chunk-size SizeSuffix         Read the source objects in chunks. (default 128M)
Sep 25 18:22:46 localhost rclone[23660]:       --vfs-read-chunk-size-limit SizeSuffix   If greater than --vfs-read-chunk-size, double the chunk size after each chunk re>
Sep 25 18:22:46 localhost rclone[23660]:       --vfs-read-wait duration                 Time to wait for in-sequence read before seeking. (default 20ms)
Sep 25 18:22:46 localhost rclone[23660]:       --vfs-write-back duration                Time to writeback files after last use when using cache. (default 5s)
Sep 25 18:22:46 localhost rclone[23660]:       --vfs-write-wait duration                Time to wait for in-sequence write before giving error. (default 1s)
Sep 25 18:22:46 localhost rclone[23660]:       --volname string                         Set the volume name (not supported by all OSes).
Sep 25 18:22:46 localhost rclone[23660]:       --write-back-cache                       Makes kernel buffer writes before sending them to rclone. Without this, writethr>
Sep 25 18:22:46 localhost rclone[23660]: Use "rclone [command] --help" for more information about a command.
Sep 25 18:22:46 localhost rclone[23660]: Use "rclone help flags" for to see the global flags.
Sep 25 18:22:46 localhost rclone[23660]: Use "rclone help backends" for a list of supported services.
Sep 25 18:22:46 localhost rclone[23660]: Command mount needs 2 arguments maximum: you provided 3 non flag arguments: ["test:" "/GD" "\\"]
Sep 25 18:22:46 localhost systemd[1]: rclone.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ An ExecStart= process belonging to unit rclone.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 1.
Sep 25 18:22:46 localhost systemd[1]: rclone.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ The unit rclone.service has entered the 'failed' state with result 'exit-code'.
Sep 25 18:22:46 localhost systemd[1]: Failed to start RClone Service.
░░ Subject: A start job for unit rclone.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ A start job for unit rclone.service has finished with a failure.
░░ 
░░ The job identifier is 224172 and the job result is failed.
Sep 25 18:22:46 localhost audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=rclone comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? a>
Sep 25 18:22:46 localhost kernel: audit: type=1130 audit(1601038366.094:8620): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=rclone comm="systemd" exe="/usr/lib/>
lines 1628-1664/1664 (END)

What is your rclone version (output from rclone version)

rclone v1.53.1

  • os/arch: linux/amd64 ( Arch Linux )
  • go version: go1.15.2

The rclone config contents with secrets removed.

[test]
type = drive
client_id = ****.googleusercontent.com
client_secret = ****
scope = drive
token = {"access_token":"****","token_type":"Bearer","refresh_token":"****","expiry":"2020-09-23T13:59:54.707321057+05:30"}
team_drive = ****
root_folder_id = 

Interestingly if i run sudo rclone mount test: /GD --allow-other --dir-cache-time 1000h --log-level INFO --log-file /opt/rclone/logs/rclone.log --poll-interval 15s --umask 002 --rc --rc-addr :5572 --rc-no-auth --vfs-cache-mode full directly in terminal ,it works well . i guess something is wrong with my rclone.service , probably someone can help me fix it

The extra slash at the end is not necessary here since it's the end of the command:

--vfs-cache-mode full \

thanks for pointing out the typo , i edited that out and ran everything again and updated the question again with relevent service status and journalctl , the errors still persist due to some reason

I assume you did a systemctl daemon-reload after making the changes?

yes i made sure that i have done it before trying to start rclone.service again

Nothing else is jumping out at me as wrong. Perhaps someone else can spot a typo elsewhere too.

Can you post the updated service file?

You should remove:

That allows over mounting and hiding and generally should not be used.

What does rclone version show?

Noted , i will remove that flag
yes , i did updated the rclone.service in question , i was just " \ " alongside --vfs-cache-mode-full

❯ rclone --version
rclone v1.53.1
- os/arch: linux/amd64
- go version: go1.15.2

If you can paste in the updated version, that would be helpful.

sorry i am not getting you , the rclone.service in my post is up-to-date with the /etc/systemd/system/rclone.service file in my local machine . i am not using any additional flag or anything different

You mean you changed the first post?

It's impossible to tell what changed in that post when you edit it as it's best to just reply as no one will have any idea you made an edit to the first post and what was changed.

The first post still has this which I thought you removed?

Please reply and paste the new service file and the new journal output showing you did a systemctl daemon-reload and the last journal part when you tried to start the service.

i changed the service file locally ( ie removed the --allow-non-empty flag ) , did a systemctl daemon-reload . After getting error on sudo systemctl start rclone.service i got a fresh service status and journalctl , i have pasted and replaced everything in original post now

Would be incredibly super awesome instead of editing the first post, you'd just reply with the new information in a reply...

❯ sudo cat /etc/systemd/system/rclone.service
[sudo] password for xd003: 
[Unit]
Description=RClone Service
Wants=network-online.target
After=network-online.target

[Service]
Type=notify
Environment=RCLONE_CONFIG=/opt/rclone/rclone.conf
KillMode=none
RestartSec=5
ExecStart=/usr/bin/rclone mount test: /GD \
--allow-other \
--dir-cache-time 1000h \ 
--log-level INFO \
--log-file /opt/rclone/logs/rclone.log \
--poll-interval 15s \
--umask 002 \
--rc \
--rc-addr :5572 \
--rc-no-auth \
--cache-dir=/cache \
--vfs-cache-mode full 
ExecStop=/bin/fusermount -uz /GD
ExecStartPost=/usr/bin/rclone rc vfs/refresh recursive=true --rc-addr 127.0.0.1:5572 _async=true
Restart=on-failure
User=xd003
Group=xd003

[Install]
WantedBy=multi-user.target
❯ sudo systemctl start rclone.service
Job for rclone.service failed because the control process exited with error code.
See "systemctl status rclone.service" and "journalctl -xe" for details.
❯ systemctl status rclone.service
● rclone.service - RClone Service
     Loaded: loaded (/etc/systemd/system/rclone.service; disabled; vendor preset: disabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2020-09-25 19:03:29 IST; 236ms ago
    Process: 29065 ExecStart=/usr/bin/rclone mount test: /GD --allow-other --dir-cache-time 1000h \ (code=exited, status=1/FAILURE)
   Main PID: 29065 (code=exited, status=1/FAILURE)

Sep 25 19:03:29 localhost systemd[1]: Failed to start RClone Service.
❯ journalctl -xe
Sep 25 19:03:39 localhost rclone[29079]:       --vfs-case-insensitive                   If a file name not found, find a case insensitive match.
Sep 25 19:03:39 localhost rclone[29079]:       --vfs-read-ahead SizeSuffix              Extra read ahead over --buffer-size when using cache-mode full.
Sep 25 19:03:39 localhost rclone[29079]:       --vfs-read-chunk-size SizeSuffix         Read the source objects in chunks. (default 128M)
Sep 25 19:03:39 localhost rclone[29079]:       --vfs-read-chunk-size-limit SizeSuffix   If greater than --vfs-read-chunk-size, double the chunk size after each chunk re>
Sep 25 19:03:39 localhost rclone[29079]:       --vfs-read-wait duration                 Time to wait for in-sequence read before seeking. (default 20ms)
Sep 25 19:03:39 localhost rclone[29079]:       --vfs-write-back duration                Time to writeback files after last use when using cache. (default 5s)
Sep 25 19:03:39 localhost rclone[29079]:       --vfs-write-wait duration                Time to wait for in-sequence write before giving error. (default 1s)
Sep 25 19:03:39 localhost rclone[29079]:       --volname string                         Set the volume name (not supported by all OSes).
Sep 25 19:03:39 localhost rclone[29079]:       --write-back-cache                       Makes kernel buffer writes before sending them to rclone. Without this, writethr>
Sep 25 19:03:39 localhost rclone[29079]: Use "rclone [command] --help" for more information about a command.
Sep 25 19:03:39 localhost rclone[29079]: Use "rclone help flags" for to see the global flags.
Sep 25 19:03:39 localhost rclone[29079]: Use "rclone help backends" for a list of supported services.
Sep 25 19:03:39 localhost rclone[29079]: Command mount needs 2 arguments maximum: you provided 3 non flag arguments: ["test:" "/GD" "\\"]
Sep 25 19:03:39 localhost systemd[1]: rclone.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ An ExecStart= process belonging to unit rclone.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 1.
Sep 25 19:03:39 localhost systemd[1]: rclone.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ The unit rclone.service has entered the 'failed' state with result 'exit-code'.
Sep 25 19:03:39 localhost systemd[1]: Failed to start RClone Service.
░░ Subject: A start job for unit rclone.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ A start job for unit rclone.service has finished with a failure.
░░ 
░░ The job identifier is 261759 and the job result is failed.
Sep 25 19:03:39 localhost audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=rclone comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? a>
Sep 25 19:03:39 localhost kernel: audit: type=1130 audit(1601040819.844:10044): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=rclone comm="systemd" exe="/usr/lib>
lines 1647-1683/1683 (END)

hi,

i am not a linux expert but i think the problem is with the formatting of the command.

as per the error output the command failed at flag
--dir-cache-time 1000h \

image

try removing that trailing space and test again.

1 Like

Removed the trailing space ,still the same issue persists

❯ sudo cat /etc/systemd/system/rclone.service
[sudo] password for xd003: 
[Unit]
Description=RClone Service
Wants=network-online.target
After=network-online.target

[Service]
Type=notify
Environment=RCLONE_CONFIG=/opt/rclone/rclone.conf
KillMode=none
RestartSec=5
ExecStart=/usr/bin/rclone mount test: /GD \
--allow-other \
--dir-cache-time 1000h \
--log-level INFO \
--log-file /opt/rclone/logs/rclone.log \
--poll-interval 15s \
--umask 002 \
--rc \
--rc-addr :5572 \
--rc-no-auth \
--cache-dir=/cache \
--vfs-cache-mode full
ExecStop=/bin/fusermount -uz /GD
ExecStartPost=/usr/bin/rclone rc vfs/refresh recursive=true --rc-addr 127.0.0.1:5572 _async=true
Restart=on-failure
User=xd003
Group=xd003

[Install]
WantedBy=multi-user.target
❯ sudo systemctl start rclone.service
Job for rclone.service failed because the control process exited with error code.
See "systemctl status rclone.service" and "journalctl -xe" for details.
❯ sudo systemctl status rclone.service
● rclone.service - RClone Service
     Loaded: loaded (/etc/systemd/system/rclone.service; disabled; vendor preset: disabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2020-09-25 19:51:29 IST; 4s ago
    Process: 33023 ExecStart=/usr/bin/rclone mount test: /GD --allow-other --dir-cache-time 1000h --log-level INFO --log-file /opt/rclone/logs/rclone.log --poll-interva>
   Main PID: 33023 (code=exited, status=1/FAILURE)
❯ journalctl -xe
░░ 
░░ A stop job for unit rclone.service has finished.
░░ 
░░ The job identifier is 306395 and the job result is done.
Sep 25 19:52:16 localhost systemd[1]: Starting RClone Service...
░░ Subject: A start job for unit rclone.service has begun execution
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ A start job for unit rclone.service has begun execution.
░░ 
░░ The job identifier is 306395.
Sep 25 19:52:17 localhost rclone[33089]: 2020/09/25 19:52:17 Failed to open log file: open /opt/rclone/logs/rclone.log: permission denied
Sep 25 19:52:17 localhost systemd[1]: rclone.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ An ExecStart= process belonging to unit rclone.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 1.
Sep 25 19:52:17 localhost systemd[1]: rclone.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ The unit rclone.service has entered the 'failed' state with result 'exit-code'.
Sep 25 19:52:17 localhost systemd[1]: Failed to start RClone Service.
░░ Subject: A start job for unit rclone.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ A start job for unit rclone.service has finished with a failure.
░░ 
░░ The job identifier is 306395 and the job result is failed.
Sep 25 19:52:17 localhost audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=rclone comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? a>
Sep 25 19:52:17 localhost kernel: audit: type=1130 audit(1601043737.061:11787): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=rclone comm="systemd" exe="/usr/lib>

As noted, the trailing spaces where the first issue.

The second is you need to make a directory to store your logs.

I use /opt for my stuff and if you don't have that directory, you'd need to customize for your environment.

i can confirm that i had created that directory quite long ago when i tried your rclone.service for the very first time .The directory still do exist
i would like to add that i can cat or access the rclone.log folder only as root ,it gives permission denied error if tried as user . Lemme try making that log file accessible to a non root user if that resolves the issue

❯ cd /opt/rclone/logs
❯ pwd
/opt/rclone/logs
❯ ls
rclone.log
❯ cat rclone.log
cat: rclone.log: Permission denied
❯ sudo -s
[sudo] password for xd003: 
[root@localhost:rclone/logs]# cat rclone.log                      (09-25 20:02)
2020/09/24 13:02:08 NOTICE: Serving remote control on http://[::]:8096/
2020/09/24 13:02:09 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2020/09/24 13:03:09 INFO  : vfs cache: cleaned: objects 2 (was 2) in use 0, to upload 0, uploading 0, total size 17.992M (was 0)
....
....
                                

What user are you running rlcone as? It seems you don't have permission to the file / directory.

i am running the service file as user 'xd003"

❯ ls -l /opt/rclone/logs/rclone.log
-rw-r----- 1 root root 614248 Sep 25 14:31 /opt/rclone/logs/rclone.log

now everything makes sense , the reason mount worked in the cli command is because i was using sudo with the rclone mount command if you noticed . Now i have 2 options , change ownership of this rclone.log file and make it accessible by user "xd003" or run the rclone.service as ExecStart=sudo /usr/bin/rclone mount test: /GD \ . what do you recommend