Detect when a mount is lost (GDrive) and reboot/force remount

I’ve noticed that every so often rclone will lose the GDrive mount which is fixed with a simple reboot, naturally it causes issues with sabnzbd/sonarr/radarr.

If i dont catch the loss in time, which is every time since im not logging in every day, sonarr/radarr comes along and does its scan and proceeds to think that it needs to redownload ALL monitored shows/movies, which of course creates a MASSIVE queue of downloads it doesn’t need, and i have to spend 2 days disabling sab/sonarr/radarr and having it rescan EVERYTHING again after i reboot and it remounts

i think it would be great if rclone could continually monitor if the connection to GDrive is still there, and if its not either force a remount or just reboot the system, or at least trigger a user provided script that could stop the sonarr/radarr service so its not thinking the folders are empty

thank you!

Edit: forgot to put OS:
Ubuntu Server 16.04

Windows or Linux? Also, what do you mean by lose the mount.

Linux, ubuntu server 16.04

By lose, it seems to just disconnect from GDrive, all the mount folders are there, but the GDrive link is gone so sab will just fill up the local folders

Here is what I use for a startup in systemd:

Description=RClone Service

ExecStart=/home/felix/go/bin/rclone cmount gcrypt: /GD \
   --allow-other \
   --dir-cache-time 48h \
   --vfs-read-chunk-size 64M \
   --vfs-read-chunk-size-limit 2G \
   --buffer-size 128M \
   --write-back-cache \
   -o auto_cache \
   -o sync_read \
   --syslog \
   --umask 002 \
   --bind \
   --log-level INFO
ExecStop=/bin/fusermount -uz /GD


That would restart if the process aborts. Are you seeing anything in the logs in regards to what rclone is doing? I’ve never had it just disappear before.

I have a sync log when the upload script runs the move command and a mount log from when the mount script mounts, but theres nothing abnormal in either, is there a default log location for all of rclone?

Thanks for the script, it could very well just be crashing

Depends on your mount:

–log-file /home/felix/logs/rclone.log
–log-level INFO or even DEBUG if you want to see what’s going on.

I’m running a bash script with some tests on different folders on my gdrive. If one of those is not found it will try and unmount and remount gdrive. Run that in crontab and go.

Would you mind providing that?

Sure, just tell me how to add it in a code block here on the forum. Trying for 10 minutes but can’t seem to manage.

I’ll give the link to the source as my script is based on that but with some more checks.