Rclone mount checking script help [SOLVED]

So I’m using the rclone mount checking script found here in cron
https://github.com/ajkis/scripts/blob/master/rclone/rclone-mount.cron
I changed all of the pathing to fit my setup and it’ll respond telling me that the mount is up from cron, and even will mount it if I run the script out side of crontab. But once in crontab if I unmount the script will just say that it’s having a critical error and cannot remount
20.04.2017 19:00:21 CRITICAL: Remount failed.

something like this, does anyone know how to fix this issue? I’ve tried everything that I can think of.

Did you create the mountcheck file on your cloud provider?
It looks to be erroring when it checks if it exists

From the script:-----------
if [[ -f "/home/plex/acdcrypt/mountcheck" ]]; then echo "$(date "+%d.%m.%Y %T") INFO: Remount successful." | tee -a "$logfile" else echo "$(date "+%d.%m.%Y %T") CRITICAL: Remount failed." | tee -a "$logfile" fi

xxxxx@pioneer ~ $ ls ~/acd
ACDETest.txt  Anime  KC  mountcheck  Movies  Music  'NAS BACKUP.zip'  'Plex Cloud Sync'  Process  springs  
Sync  TV
xxxx@pioneer ~ $ cat ~/acd/mountcheck
ACDE

When I mount it the file is present! This is what’s confusing me about this.

I have also used absolute paths to everything in the script as me using a relative path was causing issues at first.

Is that a file or a folder?
What I wound up doing was create a mountcheck.txt file and that seemed to fix the issue for me, and then of course modify the script accordingly

Just tried that and it makes no difference unfortunately. :\

20.04.2017 20:22:01 ERROR: Drive not mounted, remount in progress.
20.04.2017 20:22:01 CRITICAL: Remount failed.

Here is my edited version of the script script, edited it a bit for my privacy.

#!/bin/bash
# Change paths for mount and log file & create mountchek file.
# Add script to crontb by typig crontb -e and pasting the line bellow (without # in front )
# * * * * *  /home/plex/scripts/rclone-mount.cron >/dev/null 2>&1
# Make script executable with: chmod a+x /home/plex/scripts/rclone-mount.cron

logfile="/mnt/mpathi/xxxxx/scripts/rclone-mount.cron.log"

if pidof -o %PPID -x "rclone-mount.cron"; then
   echo "$(date "+%d.%m.%Y %T") EXIT: rclone-mount.cron already running."
   exit 1
fi

if [[ -f "/mnt/mpathi/xxxx/acd/mountcheck.txt" ]]; then
   echo "$(date "+%d.%m.%Y %T") INFO: Check successful,acdcrypt mounted." | tee -a "$logfile"
   exit
else
   echo "$(date "+%d.%m.%Y %T") ERROR: Drive not mounted, remount in progress." | tee -a "$logfile"
   # Unmount before remounting 
   fusermount -uz /mnt/mpathi/xxxxx/acd | tee -a "$logfile"
   rclone mount \
       --read-only \
       --max-read-ahead 14G \
       --acd-templink-threshold 0 \
       --checkers 16 \
       --retries 3 \
       --low-level-retries 1 \
       --timeout 30s \
       --dir-cache-time 1m \
       --quiet \
       --stats 0 \
       acd:/ /mnt/mpathi/xxxxx/acd &

   if [[ -f "/mnt/mpathi/xxxxxx/acd/mountcheck.txt" ]]; then
      echo "$(date "+%d.%m.%Y %T") INFO: Remount successful." | tee -a "$logfile"
   else
      echo "$(date "+%d.%m.%Y %T") CRITICAL: Remount failed." | tee -a "$logfile"
   fi
fi
exit

Like i said previously though, the weird part is, it just doesn’t mount through crontab. When I run the script straight from shell it works perfectly.

1 Like

maybe try the absolute path to rclone as well?

/usr/bin/rclone mount \

or where ever it’s install on your system

That was it, holy crap the simplest thing. Thank you very much!

how many times happens to you that the rclone drive disconnects?
I’m using it for a week only, but until now there were no issues

do I have to add such crontab job to check?

Yes, it’s preferred to have a cron job.

1 Like

Hi guys .

When i use Ajkis version, and add it to crontab via plexuser with sudo access. After a while the cron change the rclone.conf from plex:plex to root:plex and the system demounts without remounting?

I can see that its working and checking for the mountcheck.txt file and logs it too, but all of a sudden , it changes the user for the rclone.conf ?

Any ideas ?

Thanks
Morphy