Script to mount remote with crontab

Hello,

What is the problem you are having with rclone?

Rclone is installed with entware. It works.
I try to mount my remote on reboot with a script. So i add this command in crontab :

@reboot sh /volume1/home/user/rclone-mount.sh 2>&1 >> /volume1/home/user/reboot.log

The script seems to work because i get in the log :

Rclone is not mounted
C OK

Unfortunatly it doesn't work and the remote is not mount.

But the rclone command works outside of the script.

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

rclone 1.60.1
- os/version: unknown
- os/kernel: 5.13.x (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.19.3
- go/linking: static
- go/tags: noselfupdate

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

Mega.nz

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

The script i use :

#!/bin/sh

#script to mount rclone remote

REMOTE_BLOCK_NAME=photo

if cat /proc/mounts | grep $REMOTE_BLOCK_NAME
then
        echo "Rclone is mounted"
else
        echo "Rclone is not mounted"
        rclone mount mega:"/mini me cloud" /volume1/Rclone/Mount \
        --config="/volume1/Rclone/Config/rclone.conf" \
        --cache-dir="/volume1/Rclone/Cache" \
        --read-only \
        --timeout 1h \
        --no-modtime \
        --allow-other \
        --dir-cache-time 192h \
        --vfs-cache-max-age 195h \
        --vfs-cache-mode full \
        --vfs-cache-max-size 10G \
        --vfs-read-chunk-size-limit 2G \
        --daemon \
        --daemon-wait 5m
        #sudo mount -o bind,gid=100,uid=1000 /volume1/Rclone/Mount/photo /volume1/Photo
        echo "C OK"
fi

The rclone config contents with secrets removed.

[mega]
type = mega
user = email@email.com
pass = ***
debug = false

A log from the command with the -vv flag

Thank you in advance for the help

crontabs have no concept of paths so you need to use the full path for things you want to run.

replace rclone with the full path to where it is installed.

@Animosity022 Thank you for your answer.

I check which rclone
Then i modify to add the path:

/opt/bin/rclone mount mega:"/mini me cloud" /volume1/Rclone/Mount

It doesn't work.

I can't see your computer so saying it doesn't work without any further information doesn't work to have me help you.

Share the script you changed.
Share the error you are getting.
Share the log file you are generating.

Does that have information in it?

What's the actual error?

Hello,

Sorry for the lack of information.

To add aditionnal information, the script i run from the cron tab is :

#!/bin/sh
#script to mount rclone remote
REMOTE_BLOCK_NAME=photo
if cat /proc/mounts | grep $REMOTE_BLOCK_NAME
then
        echo "Rclone is mounted"
else
        echo "Rclone is not mounted"
        /opt/bin/rclone mount mega:"/mini me cloud" /volume1/Rclone/Mount \
        --config="/volume1/Rclone/Config/rclone.conf" \
        --cache-dir="/volume1/Rclone/Cache" \
        --read-only \
        --timeout 1h \
        --no-modtime \
        --allow-other \
        --dir-cache-time 192h \
        --vfs-cache-max-age 195h \
        --vfs-cache-mode full \
        --vfs-cache-max-size 10G \
        --vfs-read-chunk-size-limit 2G \
        --daemon \
        --daemon-wait 5m
        #sudo mount -o bind,gid=100,uid=1000 /volume1/Rclone/Mount/photo /volume1/Photo
        echo "C OK"
fi

In reboot.log, i get :

Rclone is not mounted
C OK

So i conclude the script is well executed...
But the this is the command rclone mount which doesn't work. I don't see the folder... But the command works when i run it directly...

:face_in_clouds:

Add in to your rclone part.

--log-file /some/log/file/rclone.log
--log-level DEBUG

Share the rclone log.

Hello @Animosity022,
I restart the nas. rclone.log stay empty...

Can you please share what you've changed in the script?

Hello,

The script as i modify :

#!/bin/sh
#script to mount rclone remote
REMOTE_BLOCK_NAME=photo
if cat /proc/mounts | grep $REMOTE_BLOCK_NAME
then
        echo "Rclone is mounted"
else
        echo "Rclone is not mounted"
        /opt/bin/rclone mount mega:"/mini me cloud" /volume1/Rclone/Mount \
        --config="/volume1/Rclone/Config/rclone.conf" \
        --cache-dir="/volume1/Rclone/Cache" \
        --read-only \
        --timeout 1h \
        --no-modtime \
        --allow-other \
        --dir-cache-time 192h \
        --vfs-cache-max-age 195h \
        --vfs-cache-mode full \
        --vfs-cache-max-size 10G \
        --vfs-read-chunk-size-limit 2G \
        --daemon \
        --daemon-wait 5m \
        --log-file="/volume1/home/jbo/rclone.log" \
        --log-level DEBUG \
        -vv
        #sudo mount -o bind,gid=100,uid=1000 /volume1/Rclone/Mount/photo /volume1/Photo
        echo "C OK"
fi

The file rclone.log stay empty. :face_with_diagonal_mouth:

you realize that he's askinig you for more detailed information so that he can help to the best of his ability right?

Without things like the log (which if you're not seeing a log you've either pointed rclone to output log info to a directory that doesn't exist. Therefore, mkdir /volume1/home/jbo/ and then touch /volume1/home/jbo/rclone.log

If you're truely not getting any log output after that, maybe best to remove/comment out --log-file= and replace with --syslog and open a second terminal. In second terminal, enter sudo tail -n 500 -F /var/log/syslog and run your script. Now copy and paste the log output, which will now be output to your syslog.

Sometimes it's hard to remember that folks around here help out of the kindness of their hearts and not due to employment. Therefore, They really are not obligated to help. But providing them detailed info, when requesting some help goes a long way in helping them solve or potentially point you in the direction of a solution to your issue,

Something isn't correct then as if you've changed that and rclone is running.

You'd get:

felix@gemini:~$ rclone mount GD: /home/felix/test --log-file blah.log -vv --daemon
2023/02/11 06:56:22 DEBUG : Setting --config "/opt/rclone/rclone.conf" from environment variable RCLONE_CONFIG="/opt/rclone/rclone.conf"
felix@gemini:~$ cat blah.log
2023/02/11 06:56:22 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "mount" "GD:" "/home/felix/test" "--log-file" "blah.log" "-vv" "--daemon"]
2023/02/11 06:56:22 DEBUG : Creating backend with remote "GD:"
2023/02/11 06:56:22 DEBUG : Using config file from "/opt/rclone/rclone.conf"
2023/02/11 06:56:22 DEBUG : rclone: Version "v1.61.1" starting with parameters ["/usr/bin/rclone" "mount" "GD:" "/home/felix/test" "--log-file" "blah.log" "-vv" "--daemon"]
2023/02/11 06:56:22 DEBUG : Creating backend with remote "GD:"
2023/02/11 06:56:22 DEBUG : Using config file from "/opt/rclone/rclone.conf"
2023/02/11 06:56:22 DEBUG : GD: Loaded invalid token from config file - ignoring
2023/02/11 06:56:22 DEBUG : Saving config "token" in section "GD" of the config file
2023/02/11 06:56:22 DEBUG : Keeping previous permissions for config file: -rwxrwxr-x
2023/02/11 06:56:22 DEBUG : GD: Saved new token in config file
2023/02/11 06:56:22 DEBUG : Google drive root '': Mounting on "/home/felix/test"
2023/02/11 06:56:22 DEBUG : : Root:
2023/02/11 06:56:22 DEBUG : : >Root: node=/, err=<nil>
2023/02/11 06:56:22 DEBUG : rclone: Version "v1.61.1" finishing with parameters ["/usr/bin/rclone" "mount" "GD:" "/home/felix/test" "--log-file" "blah.log" "-vv" "--daemon"]

Something in the log file.

Change that to

#!/bin/sh -x

and reboot, It will log all the commands as that's debug for the shell.

Share the full output of these commands. Type in shell and share.

cat /volume1/home/user/reboot.log
cat /volume1/home/jbo/rclone.log

Hello,

@gsatv01
I am fully aware of the difficulties in helping someone. If I don't give information, it's not out of contempt or negligence but because I didn't know what information to give. Sorry for the inconvenience and for the misunderstanding....

@Animosity022
Thank you for your answer.
So i make two tests to compare.


First of all i try to reboot with the following script :

#!/bin/sh -x

#script to mount rclone remote

REMOTE_BLOCK_NAME=photo

if cat /proc/mounts | grep $REMOTE_BLOCK_NAME
then
        echo "Rclone is mounted"
else
        date
        echo "Rclone is not mounted"
        /opt/bin/rclone mount mega:"/mini me cloud" /volume1/Rclone/Mount \
        --config="/volume1/Rclone/Config/rclone.conf" \
        --cache-dir="/volume1/Rclone/Cache" \
        --read-only \
        --timeout 1h \
        --no-modtime \
        --allow-other \
        --dir-cache-time 192h \
        --vfs-cache-max-age 195h \
        --vfs-cache-mode full \
        --vfs-cache-max-size 10G \
        --vfs-read-chunk-size-limit 2G \
        --daemon \
        --daemon-wait 5m \
        --log-file="/volume1/Rclone/rclone.log" \
        --log-level DEBUG 
        #sudo mount -o bind,gid=100,uid=1000 /volume1/Rclone/Mount/photo /volume1/Photo
        echo "C OK"
fi

The rclone.log stay empty :

$ cat /volume1/Rclone/rclone.log

$

But the script works :

$ cat /volume1/home/jbo/reboot.log
Mon Feb 13 23:16:00 CET 2023
Rclone is not mounted
C OK
$ 

When i mount the remote directly :

$ rclone mount mega:"/mini me cloud" /volume1/Rclone/Mount -
-config="/volume1/Rclone/Config/rclone.conf" --cache-dir="/volume1/Rclone/Cache" --read-only --time
out 1h --no-modtime --allow-other --dir-cache-time 192h --vfs-cache-max-age 195h --vfs-cache-mode f
ull --vfs-cache-max-size 10G --vfs-read-chunk-size-limit 2G --daemon --daemon-wait 5m --log-file="/
volume1/Rclone/rclone.log" --log-level DEBUG
$ 

The rclone.log is full (extract) :

$ cat /volume1/Rclone/rclone.log

2023/02/13 23:19:56 DEBUG : rclone: Version "1.60.1" starting with parameters ["rclone" "mount" "mega:/mini me cloud" "/volume1/Rclone/Mount" "--config=/volume1/Rclone/Config/rclone.conf" "--cache-dir=/volume1/Rclone/Cache" "--read-only" "--timeout" "1h" "--no-modtime" "--allow-other" "--dir-cache-time" "192h" "--vfs-cache-max-age" "195h" "--vfs-cache-mode" "full" "--vfs-cache-max-size" "10G" "--vfs-read-chunk-size-limit" "2G" "--daemon" "--daemon-wait" "5m" "--log-file=/volume1/Rclone/rclone.log" "--log-level" "DEBUG"]
2023/02/13 23:19:56 DEBUG : Creating backend with remote "mega:/mini me cloud"
2023/02/13 23:19:56 DEBUG : Using config file from "/volume1/Rclone/Config/rclone.conf"
2023/02/13 23:23:22 DEBUG : fs cache: renaming cache item "mega:/mini me cloud" to be canonical "mega:mini me cloud"
2023/02/13 23:23:22 DEBUG : rclone: Version "1.60.1" starting with parameters ["/volume1/.@plugins/AppCentral/entware/opt/bin/rclone" "mount" "mega:/mini me cloud" "/volume1/Rclone/Mount" "--config=/volume1/Rclone/Config/rclone.conf" "--cache-dir=/volume1/Rclone/Cache" "--read-only" "--timeout" "1h" "--no-modtime" "--allow-other" "--dir-cache-time" "192h" "--vfs-cache-max-age" "195h" "--vfs-cache-mode" "full" "--vfs-cache-max-size" "10G" "--vfs-read-chunk-size-limit" "2G" "--daemon" "--daemon-wait" "5m" "--log-file=/volume1/Rclone/rclone.log" "--log-level" "DEBUG"]
2023/02/13 23:23:22 DEBUG : Creating backend with remote "mega:/mini me cloud"
2023/02/13 23:23:22 DEBUG : Using config file from "/volume1/Rclone/Config/rclone.conf"
2023/02/13 23:26:16 DEBUG : fs cache: renaming cache item "mega:/mini me cloud" to be canonical "mega:mini me cloud"
2023/02/13 23:26:16 INFO  : mega root 'mini me cloud': poll-interval is not supported by this remote
2023/02/13 23:26:16 DEBUG : vfs cache: root is "/volume1/Rclone/Cache"
2023/02/13 23:26:16 DEBUG : vfs cache: data root is "/volume1/Rclone/Cache/vfs/mega/mini me cloud"
2023/02/13 23:26:16 DEBUG : vfs cache: metadata root is "/volume1/Rclone/Cache/vfsMeta/mega/mini me cloud"
2023/02/13 23:26:16 DEBUG : Creating backend with remote "/volume1/Rclone/Cache/vfs/mega/mini me cloud"
2023/02/13 23:26:16 DEBUG : Creating backend with remote "/volume1/Rclone/Cache/vfsMeta/mega/mini me cloud"
2023/02/13 23:26:25 DEBUG : mega root 'mini me cloud': Mounting on "/volume1/Rclone/Mount"
2023/02/13 23:26:25 DEBUG : vfs cache RemoveNotInUse (maxAge=702000000000000, emptyOnly=false): item photo/robin/7eme mois/P1030033.JPG not removed, freed 0 bytes
2023/02/13 23:26:25 DEBUG : vfs cache RemoveNotInUse (maxAge=702000000000000, emptyOnly=false): item photo/robin/8eme mois/Tunisie/P1050214.JPG not removed, freed 0 bytes
2023/02/13 23:26:25 DEBUG : vfs cache RemoveNotInUse (maxAge=702000000000000, emptyOnly=false): item photo/robin/8eme mois/Tunisie/P1050266.RW2 not removed, freed 0 bytes
2023/02/13 23:26:25 DEBUG : vfs cache RemoveNotInUse (maxAge=702000000000000, emptyOnly=false): item photo/robin/8eme mois/Tunisie/P1050218.JPG not removed, freed 0 bytes
2023/02/13 23:26:25 DEBUG : vfs cache RemoveNotInUse (maxAge=702000000000000, emptyOnly=false): item photo/robin/9eme mois/P1050624.JPG not removed, freed 0 bytes
2023/02/13 23:26:25 DEBUG : vfs cache RemoveNotInUse (maxAge=702000000000000, emptyOnly=false): item photo/robin/8eme mois/P1050455.RW2 not removed, freed 0 bytes
2023/02/13 23:26:25 DEBUG : vfs cache RemoveNotInUse (maxAge=702000000000000, emptyOnly=false): item photo/robin/8eme mois/Tunisie/P1050222.RW2 not removed, freed 0 bytes
2023/02/13 23:26:25 DEBUG : vfs cache RemoveNotInUse (maxAge=702000000000000, emptyOnly=false): item photo/robin/8eme mois/Tunisie/P1050440.RW2 not removed, freed 0 bytes
2023/02/13 23:26:25 DEBUG : vfs cache RemoveNotInUse (maxAge=702000000000000, emptyOnly=false): item photo/robin/4eme mois/IMG_20180221_164820488.jpg not removed, freed 0 bytes
2023/02/13 23:26:25 DEBUG : vfs cache RemoveNotInUse (maxAge=702000000000000, emptyOnly=false): item photo/robin/7eme mois/P1050050.JPG not removed, freed 0 bytes
$

So i conclued, the problem in the script is at :face_with_diagonal_mouth:
/opt/bin/rclone mount mega:"/mini me cloud" /volume1/Rclone/Mount \


That all the information i get now.
I will stay investigating.

Thank you in advance for the help.

I change the path to rclone :

#!/bin/sh -x
#script to mount rclone remote
REMOTE_BLOCK_NAME=photo
if cat /proc/mounts | grep $REMOTE_BLOCK_NAME
then
        echo "Rclone is mounted"
else
        date
        echo "Rclone is not mounted"
        /volume1/.@plugins/AppCentral/entware/opt/bin/rclone mount mega:"/mini me cloud" /volume1/Rclone/Mount \
        --config="/volume1/Rclone/Config/rclone.conf" \
        --cache-dir="/volume1/Rclone/Cache" \
        --read-only \
        --timeout 1h \
        --no-modtime \
        --allow-other \
        --dir-cache-time 192h \
        --vfs-cache-max-age 195h \
        --vfs-cache-mode full \
        --vfs-cache-max-size 10G \
        --vfs-read-chunk-size-limit 2G \
        --daemon \
        --daemon-wait 5m \
        --log-file="/volume1/Rclone/rclone.log" \
        --log-level DEBUG 
        #sudo mount -o bind,gid=100,uid=1000 /volume1/Rclone/Mount/photo /volume1/Photo
        echo "C OK"
fi

It seems to start working if i refer to the log file :

$ cat /volume1/Rclone/rclone.log
2023/02/14 20:33:26 DEBUG : rclone: Version "1.60.1" starting with parameters ["/volume1/.@plugins/AppCentral/entware/opt/bin/rclone" "mount" "mega:/mini me cloud" "/volume1/Rclone/Mount" "--config=/volume1/Rclone/Config/rclone.conf" "--cache-dir=/volume1/Rclone/Cache" "--read-only" "--timeout" "1h" "--no-modtime" "--allow-other" "--dir-cache-time" "192h" "--vfs-cache-max-age" "195h" "--vfs-cache-mode" "full" "--vfs-cache-max-size" "10G" "--vfs-read-chunk-size-limit" "2G" "--daemon" "--daemon-wait" "5m" "--log-file=/volume1/Rclone/rclone.log" "--log-level" "DEBUG"]
2023/02/14 20:33:26 DEBUG : Creating backend with remote "mega:/mini me cloud"
2023/02/14 20:33:26 DEBUG : Using config file from "/volume1/Rclone/Config/rclone.conf"
$

... Unfortunately the mount process doesn't seems to go to the end.

...:/volume1/Rclone/Mount $ ls -la
total 8
drwxr-xr-x    2 admin    administ      4096 Jan 22 17:34 ./
drwxrwxrwx    5 admin    administ      4096 Feb 13 07:02 ../
...:/volume1/Rclone/Mount $

There's no log file in the script you've pasted in on your modified script.

Thank you @Animosity022 for the quick answer.
It's a confusion into the file i save the script in outside the nas.

The only modification is the path /volume1/.@plugins/AppCentral/entware/opt/bin/rclone

And the log is real :

$ cat /volume1/Rclone/rclone.log
2023/02/14 20:33:26 DEBUG : rclone: Version "1.60.1" starting with parameters ["/volume1/.@plugins/AppCentral/entware/opt/bin/rclone" "mount" "mega:/mini me cloud" "/volume1/Rclone/Mount" "--config=/volume1/Rclone/Config/rclone.conf" "--cache-dir=/volume1/Rclone/Cache" "--read-only" "--timeout" "1h" "--no-modtime" "--allow-other" "--dir-cache-time" "192h" "--vfs-cache-max-age" "195h" "--vfs-cache-mode" "full" "--vfs-cache-max-size" "10G" "--vfs-read-chunk-size-limit" "2G" "--daemon" "--daemon-wait" "5m" "--log-file=/volume1/Rclone/rclone.log" "--log-level" "DEBUG"]
2023/02/14 20:33:26 DEBUG : Creating backend with remote "mega:/mini me cloud"
2023/02/14 20:33:26 DEBUG : Using config file from "/volume1/Rclone/Config/rclone.conf"
$

I try to restart manually the script :

$ sh /volume1/home/jbo/rclone-mount.sh
Tue Feb 14 21:54:11 CET 2023
Rclone is not mounted
C OK
$ 

And it seems to work.

So i guess i have to try to restart again... Maybe the remote is very slow to be mounted.

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