Raspberry Pi script will not exit after mounting Onedrive

#### What is the problem you are having with rclone?

I have a Raspberry Pi script to mount a Onedrive. The script runs fine and mounts Onedrive, but the script never exits on completion. I have tried using exit and return to no avail. As soon as I use Ctrl-C the script exits but the Onedrive is dismounted.

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

``rclone v1.68.1

  • os/version: raspbian 11.11 (64 bit)
  • os/kernel: 6.1.21-v8+ (aarch64)
  • os/type: linux
  • os/arch: arm64 (ARMv8 compatible)
  • go/version: go1.23.1
  • go/linking: static
  • go/tags: none

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

Onedrive



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

rclone --vfs-cache-mode writes mount onedrive: ~/onedrive



#### Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

[onedrive]
type = onedrive
token = XXX
drive_id = XXX
drive_type = personal

#### A log from the command that you were trying to run with the `-vv` flag  

```I have only included the last part of the log (the rest completes succesfully but has private information in it) as this shows where the script appears to stop```

2024/10/16 17:16:20 DEBUG : vfs cache RemoveNotInUse (maxAge=3600000000000, emptyOnly=false): item RaspberryPi/.~lock.Raspberry General Commands.docxï¼ not removed, freed 0 bytes
2024/10/16 17:16:20 INFO : vfs cache: cleaned: objects 1 (was 1) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/16 17:17:20 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/16 17:17:20 DEBUG : vfs cache RemoveNotInUse (maxAge=3600000000000, emptyOnly=false): item RaspberryPi/.~lock.Raspberry General Commands.docxï¼ not removed, freed 0 bytes
2024/10/16 17:17:20 INFO : vfs cache: cleaned: objects 1 (was 1) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/16 17:18:20 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/16 17:18:20 DEBUG : vfs cache RemoveNotInUse (maxAge=3600000000000, emptyOnly=false): item RaspberryPi/.~lock.Raspberry General Commands.docxï¼ not removed, freed 0 bytes
2024/10/16 17:18:20 INFO : vfs cache: cleaned: objects 1 (was 1) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/16 17:19:20 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/16 17:19:20 DEBUG : vfs cache RemoveNotInUse (maxAge=3600000000000, emptyOnly=false): item RaspberryPi/.~lock.Raspberry General Commands.docxï¼ not removed, freed 0 bytes
2024/10/16 17:19:20 INFO : vfs cache: cleaned: objects 1 (was 1) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/16 17:20:20 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/16 17:20:20 DEBUG : vfs cache RemoveNotInUse (maxAge=3600000000000, emptyOnly=false): item RaspberryPi/.~lock.Raspberry General Commands.docxï¼ not removed, freed 0 bytes
2024/10/16 17:20:20 INFO : vfs cache: cleaned: objects 1 (was 1) in use 0, to upload 0, uploading 0, total size 0 (was 0)

Use systemd. Plenty of examples and how to-s on Google and this forum.

Thanks for that reply.
I am new to Raspberry Pi/Linux and not familiar with systemd. I will need sometime to investigate.
I am curious though that as to why systemd might overcome the problem of my script stalling if it appears to have nothing wrong with it?

Update to reply given above##

Yesterday I left the script running and did not exit. When I took a look just now, I can see that the script is not actually stalling or hanging but it is continuing to run, by continuing to check for changes on the remote drive. Surely this isn't the only way the rclone command should work? Is there not a flag to tell it once it has completed the mount successfully, it should exit its operation and not continue to check for changes?
Is it perhaps the --vfs-cache flag that is causing this to happen?

2024/10/17 12:56:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 12:56:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 12:57:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 12:57:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 12:58:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 12:58:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 12:59:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 12:59:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:00:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:00:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:01:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:01:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:02:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:02:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:03:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:03:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:04:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:04:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:05:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:05:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:06:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:06:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:07:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:07:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:08:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:08:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:09:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:09:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:10:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:10:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:11:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:11:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:12:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:12:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:13:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:13:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:14:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:14:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:15:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:15:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:16:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:16:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:17:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:17:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:18:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:18:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:19:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:19:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:20:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:20:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:21:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:21:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:22:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:22:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:23:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:23:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:24:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:24:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:25:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:25:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:26:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:26:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:27:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:27:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:28:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:28:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:29:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:29:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:30:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:30:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:31:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:31:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:31:55 DEBUG : : changeNotify: relativePath="root", type=0
2024/10/17 13:31:55 DEBUG : : >changeNotify: 
2024/10/17 13:31:55 DEBUG : : changeNotify: relativePath="Documents", type=0
2024/10/17 13:31:55 DEBUG : : >changeNotify: 
2024/10/17 13:31:55 DEBUG : : changeNotify: relativePath="Documents/Investing", type=0
2024/10/17 13:31:55 DEBUG : : >changeNotify: 
2024/10/17 13:31:55 DEBUG : : changeNotify: relativePath="Documents/Investing/Investments", type=0
2024/10/17 13:31:55 DEBUG : : >changeNotify: 
2024/10/17 13:31:55 DEBUG : : changeNotify: relativePath="Documents/Investing/Investments/Portfolio Management", type=0
2024/10/17 13:31:55 DEBUG : : >changeNotify: 
2024/10/17 13:31:55 DEBUG : : changeNotify: relativePath="Documents/Investing/Investments/Portfolio Management/Ian King.xlsx", type=1
2024/10/17 13:31:55 DEBUG : : >changeNotify: 
2024/10/17 13:32:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:32:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:33:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:33:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:34:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:34:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:35:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:35:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:36:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:36:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:37:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:37:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/10/17 13:38:55 DEBUG : OneDrive root '': Checking for changes on remote
2024/10/17 13:38:55 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
^C2024/10/17 13:39:18 INFO  : Signal received: interrupt
2024/10/17 13:39:18 DEBUG : vfs cache: cleaner exiting
2024/10/17 13:39:18 ERROR : /home/pi/onedrive: Unmounted rclone mount
2024/10/17 13:39:18 INFO  : Exiting...

if you want to access the files, the mount command has to continue to run all the time,
in the foreground or background.
if you kill the mount command, then cannot access the files.

that is just the way it works, there is no way around that.


there are many simpler ways to run rclone in the background.
rclone itself has a way as per the rclone docs
Use the --daemon flag to force background mode
or can use cron, bg, screen and what i use which is tmux

no

Use fstab, you can find an example on the rclone mount manpage.

Thank you for all your responses.
At first I didn't appreciate that rclone must run continuously in the background as a service and if terminated the mounted filesystem will cease to exist.
I will now investigate the suggestions you have made thus avoiding the open console window.
Thank you for your help.

After much messing around with systemd I eventually got this to work.

1 Like

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