Rclone Won't Mount Drive If Run Through Task Scheduler

What is the problem you are having with rclone?

I can successfully mount an s3 bucket with a batch script as an administrator user. When I try to run that same batch script through the Task Scheduler, the bucket never mounts.

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

C:\Users\Administrator>rclone version
rclone v1.62.2
- os/version: Microsoft Windows Server 2022 Datacenter 21H2 (64 bit)
- os/kernel: 10.0.20348.1547 Build 20348.1547.1547 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.20.2
- go/linking: static
- go/tags: cmount

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

AWS s3 bucket

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

batch script "MountS3Bucket.bat"

set LOGFILE=C:\Jenkins\s3_bucket_mount.log
del %LOGFILE%
"C:\Program Files\rclone\rclone.exe" --config=C:\Users\Administrator\AppData\Roaming\rclone\rclone.conf mount aws_[REDACTED1]_packages:[REDACTED2]-packages S: --vfs-cache-mode full --log-file %LOGFILE% --log-level DEBUG

The rclone config contents with secrets removed.

[aws_[REDACTED1]_packages]
type = s3
provider = AWS
env_auth = true
region = us-west-2

A log from the command with the -vv flag

To run the script in the desired method for this template, I removed --log-level DEBUG and replaced it with -vv (trying to set both made the script fail to run).

Successful run obtained by double clicking the batch script:

2023/05/20 02:18:59 DEBUG : rclone: Version "v1.62.2" starting with parameters ["C:\\Program Files\\rclone\\rclone.exe" "--config=C:\\Users\\Administrator\\AppData\\Roaming\\rclone\\rclone.conf" "mount" "aws_[REDACTED1]_packages:[REDACTED2]-packages" "S:" "--vfs-cache-mode" "full" "--no-console" "--log-file" "C:\\Jenkins\\s3_bucket_mount.log" "-vv"]
2023/05/20 02:18:59 DEBUG : Creating backend with remote "aws_[REDACTED1]_packages:[REDACTED2]-packages"
2023/05/20 02:18:59 DEBUG : Using config file from "C:\\Users\\Administrator\\AppData\\Roaming\\rclone\\rclone.conf"
2023/05/20 02:18:59 INFO  : S3 bucket [REDACTED2]-packages: poll-interval is not supported by this remote
2023/05/20 02:18:59 DEBUG : vfs cache: root is "C:\\Users\\Administrator\\AppData\\Local\\rclone"
2023/05/20 02:18:59 DEBUG : vfs cache: data root is "\\\\?\\C:\\Users\\Administrator\\AppData\\Local\\rclone\\vfs\\aws_[REDACTED1]_packages\\[REDACTED2]-packages"
2023/05/20 02:18:59 DEBUG : vfs cache: metadata root is "\\\\?\\C:\\Users\\Administrator\\AppData\\Local\\rclone\\vfsMeta\\aws_[REDACTED1]_packages\\[REDACTED2]-packages"
2023/05/20 02:18:59 DEBUG : Creating backend with remote "C:/Users/Administrator/AppData/Local/rclone/vfs/aws_[REDACTED1]_packages/[REDACTED2]-packages"
2023/05/20 02:18:59 DEBUG : fs cache: renaming cache item "C:/Users/Administrator/AppData/Local/rclone/vfs/aws_[REDACTED1]_packages/[REDACTED2]-packages" to be canonical "//?/C:/Users/Administrator/AppData/Local/rclone/vfs/aws_[REDACTED1]_packages/[REDACTED2]-packages"
2023/05/20 02:18:59 DEBUG : Creating backend with remote "C:/Users/Administrator/AppData/Local/rclone/vfsMeta/aws_[REDACTED1]_packages/[REDACTED2]-packages"
2023/05/20 02:18:59 DEBUG : fs cache: renaming cache item "C:/Users/Administrator/AppData/Local/rclone/vfsMeta/aws_[REDACTED1]_packages/[REDACTED2]-packages" to be canonical "//?/C:/Users/Administrator/AppData/Local/rclone/vfsMeta/aws_[REDACTED1]_packages/[REDACTED2]-packages"
2023/05/20 02:18:59 DEBUG : Network mode mounting is disabled
2023/05/20 02:18:59 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2023/05/20 02:18:59 DEBUG : Mounting on "S:" ("aws_[REDACTED1]_packages [REDACTED3]")
2023/05/20 02:18:59 DEBUG : S3 bucket [REDACTED2]-packages: Mounting with options: ["-o" "attr_timeout=1" "-o" "uid=-1" "-o" "gid=-1" "--FileSystemName=rclone" "-o" "volname=aws_[REDACTED1]_packages [REDACTED3]"]
2023/05/20 02:18:59 DEBUG : S3 bucket [REDACTED2]-packages: Init: 
2023/05/20 02:18:59 DEBUG : S3 bucket [REDACTED2]-packages: >Init: 
2023/05/20 02:18:59 DEBUG : /: Statfs: 
2023/05/20 02:18:59 DEBUG : /: >Statfs: stat={Bsize:4096 Frsize:4096 Blocks:274877906944 Bfree:274877906944 Bavail:274877906944 Files:1000000000 Ffree:1000000000 Favail:0 Fsid:0 Flag:0 Namemax:255}, errc=0
2023/05/20 02:18:59 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:18:59 DEBUG : /: >Getattr: errc=0
2023/05/20 02:18:59 DEBUG : /: Readlink: 
2023/05/20 02:18:59 DEBUG : /: >Readlink: linkPath="", errc=-40
2023/05/20 02:18:59 DEBUG : /: Getxattr: name="non-existant-a11ec902d22f4ec49003af15282d3b00"
2023/05/20 02:18:59 DEBUG : /: >Getxattr: errc=-40, value=""
The service rclone has been started.
2023/05/20 02:18:59 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:18:59 DEBUG : /: >Getattr: errc=0
2023/05/20 02:18:59 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:18:59 DEBUG : /: >Getattr: errc=0
2023/05/20 02:18:59 DEBUG : /: Opendir: 
2023/05/20 02:18:59 DEBUG : /: OpenFile: flags=O_RDONLY, perm=-rwxrwxrwx
2023/05/20 02:18:59 DEBUG : /: >OpenFile: fd=/ (r), err=<nil>
2023/05/20 02:18:59 DEBUG : /: >Opendir: errc=0, fh=0x0
2023/05/20 02:18:59 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:18:59 DEBUG : /: >Getattr: errc=0
2023/05/20 02:18:59 DEBUG : /: Releasedir: fh=0x0
2023/05/20 02:18:59 DEBUG : /: >Releasedir: errc=0
2023/05/20 02:18:59 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:18:59 DEBUG : /: >Getattr: errc=0
2023/05/20 02:18:59 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:18:59 DEBUG : /: >Getattr: errc=0
2023/05/20 02:18:59 DEBUG : /: Opendir: 
2023/05/20 02:18:59 DEBUG : /: OpenFile: flags=O_RDONLY, perm=-rwxrwxrwx
2023/05/20 02:18:59 DEBUG : /: >OpenFile: fd=/ (r), err=<nil>
2023/05/20 02:18:59 DEBUG : /: >Opendir: errc=0, fh=0x0
2023/05/20 02:18:59 DEBUG : /: Releasedir: fh=0x0
2023/05/20 02:18:59 DEBUG : /: >Releasedir: errc=0
2023/05/20 02:18:59 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:18:59 DEBUG : /: >Getattr: errc=0
2023/05/20 02:18:59 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:18:59 DEBUG : /: >Getattr: errc=0
2023/05/20 02:18:59 DEBUG : /: Opendir: 
2023/05/20 02:18:59 DEBUG : /: OpenFile: flags=O_RDONLY, perm=-rwxrwxrwx
2023/05/20 02:18:59 DEBUG : /: >OpenFile: fd=/ (r), err=<nil>
2023/05/20 02:18:59 DEBUG : /: >Opendir: errc=0, fh=0x0
2023/05/20 02:18:59 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:18:59 DEBUG : /: >Getattr: errc=0
2023/05/20 02:18:59 DEBUG : /: Releasedir: fh=0x0
2023/05/20 02:18:59 DEBUG : /: >Releasedir: errc=0
2023/05/20 02:19:59 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2023/05/20 02:20:59 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2023/05/20 02:21:59 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)

Failed run by starting the task through Task Scheduler:

2023/05/20 02:27:17 DEBUG : rclone: Version "v1.62.2" starting with parameters ["C:\\Program Files\\rclone\\rclone.exe" "--config=C:\\Users\\Administrator\\AppData\\Roaming\\rclone\\rclone.conf" "mount" "aws_[REDACTED1]_packages:[REDACTED2]-packages" "S:" "--vfs-cache-mode" "full" "--no-console" "--log-file" "C:\\Jenkins\\s3_bucket_mount.log" "-vv"]
2023/05/20 02:27:17 DEBUG : Creating backend with remote "aws_[REDACTED1]_packages:[REDACTED2]-packages"
2023/05/20 02:27:17 DEBUG : Using config file from "C:\\Users\\Administrator\\AppData\\Roaming\\rclone\\rclone.conf"
2023/05/20 02:27:17 INFO  : S3 bucket [REDACTED2]-packages: poll-interval is not supported by this remote
2023/05/20 02:27:17 DEBUG : vfs cache: root is "C:\\Users\\Administrator\\AppData\\Local\\rclone"
2023/05/20 02:27:17 DEBUG : vfs cache: data root is "\\\\?\\C:\\Users\\Administrator\\AppData\\Local\\rclone\\vfs\\aws_[REDACTED1]_packages\\[REDACTED2]-packages"
2023/05/20 02:27:17 DEBUG : vfs cache: metadata root is "\\\\?\\C:\\Users\\Administrator\\AppData\\Local\\rclone\\vfsMeta\\aws_[REDACTED1]_packages\\[REDACTED2]-packages"
2023/05/20 02:27:17 DEBUG : Creating backend with remote "C:/Users/Administrator/AppData/Local/rclone/vfs/aws_[REDACTED1]_packages/[REDACTED2]-packages"
2023/05/20 02:27:17 DEBUG : fs cache: renaming cache item "C:/Users/Administrator/AppData/Local/rclone/vfs/aws_[REDACTED1]_packages/[REDACTED2]-packages" to be canonical "//?/C:/Users/Administrator/AppData/Local/rclone/vfs/aws_[REDACTED1]_packages/[REDACTED2]-packages"
2023/05/20 02:27:17 DEBUG : Creating backend with remote "C:/Users/Administrator/AppData/Local/rclone/vfsMeta/aws_[REDACTED1]_packages/[REDACTED2]-packages"
2023/05/20 02:27:17 DEBUG : fs cache: renaming cache item "C:/Users/Administrator/AppData/Local/rclone/vfsMeta/aws_[REDACTED1]_packages/[REDACTED2]-packages" to be canonical "//?/C:/Users/Administrator/AppData/Local/rclone/vfsMeta/aws_[REDACTED1]_packages/[REDACTED2]-packages"
2023/05/20 02:27:17 DEBUG : Network mode mounting is disabled
2023/05/20 02:27:17 DEBUG : Mounting on "S:" ("aws_[REDACTED1]_packages [REDACTED3]")
2023/05/20 02:27:17 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2023/05/20 02:27:17 DEBUG : S3 bucket [REDACTED2]-packages: Mounting with options: ["-o" "attr_timeout=1" "-o" "uid=-1" "-o" "gid=-1" "--FileSystemName=rclone" "-o" "volname=aws_[REDACTED1]_packages [REDACTED3]"]
2023/05/20 02:27:17 DEBUG : S3 bucket [REDACTED2]-packages: Init: 
2023/05/20 02:27:17 DEBUG : S3 bucket [REDACTED2]-packages: >Init: 
2023/05/20 02:27:17 DEBUG : /: Statfs: 
2023/05/20 02:27:17 DEBUG : /: >Statfs: stat={Bsize:4096 Frsize:4096 Blocks:274877906944 Bfree:274877906944 Bavail:274877906944 Files:1000000000 Ffree:1000000000 Favail:0 Fsid:0 Flag:0 Namemax:255}, errc=0
2023/05/20 02:27:17 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:27:17 DEBUG : /: >Getattr: errc=0
2023/05/20 02:27:17 DEBUG : /: Readlink: 
2023/05/20 02:27:17 DEBUG : /: >Readlink: linkPath="", errc=-40
2023/05/20 02:27:17 DEBUG : /: Getxattr: name="non-existant-a11ec902d22f4ec49003af15282d3b00"
2023/05/20 02:27:17 DEBUG : /: >Getxattr: errc=-40, value=""
2023/05/20 02:27:17 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:27:17 DEBUG : /: >Getattr: errc=0
2023/05/20 02:27:17 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:27:17 DEBUG : /: >Getattr: errc=0
2023/05/20 02:27:17 DEBUG : /: Opendir: 
2023/05/20 02:27:17 DEBUG : /: OpenFile: flags=O_RDONLY, perm=-rwxrwxrwx
2023/05/20 02:27:17 DEBUG : /: >OpenFile: fd=/ (r), err=<nil>
2023/05/20 02:27:17 DEBUG : /: >Opendir: errc=0, fh=0x0
2023/05/20 02:27:17 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:27:17 DEBUG : /: >Getattr: errc=0
2023/05/20 02:27:17 DEBUG : /: Releasedir: fh=0x0
2023/05/20 02:27:17 DEBUG : /: >Releasedir: errc=0
2023/05/20 02:27:17 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:27:17 DEBUG : /: >Getattr: errc=0
2023/05/20 02:27:17 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:27:17 DEBUG : /: >Getattr: errc=0
2023/05/20 02:27:17 DEBUG : /: Opendir: 
2023/05/20 02:27:17 DEBUG : /: OpenFile: flags=O_RDONLY, perm=-rwxrwxrwx
2023/05/20 02:27:17 DEBUG : /: >OpenFile: fd=/ (r), err=<nil>
2023/05/20 02:27:17 DEBUG : /: >Opendir: errc=0, fh=0x0
2023/05/20 02:27:17 DEBUG : /: Releasedir: fh=0x0
2023/05/20 02:27:17 DEBUG : /: >Releasedir: errc=0
2023/05/20 02:27:17 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:27:17 DEBUG : /: >Getattr: errc=0
2023/05/20 02:27:17 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:27:17 DEBUG : /: >Getattr: errc=0
2023/05/20 02:27:17 DEBUG : /: Opendir: 
2023/05/20 02:27:17 DEBUG : /: OpenFile: flags=O_RDONLY, perm=-rwxrwxrwx
2023/05/20 02:27:17 DEBUG : /: >OpenFile: fd=/ (r), err=<nil>
2023/05/20 02:27:17 DEBUG : /: >Opendir: errc=0, fh=0x0
2023/05/20 02:27:17 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2023/05/20 02:27:17 DEBUG : /: >Getattr: errc=0
2023/05/20 02:27:17 DEBUG : /: Releasedir: fh=0x0
2023/05/20 02:27:17 DEBUG : /: >Releasedir: errc=0

Task Scheduler task configuration:
General Tab:
Running as user: Administrator
Run whether user is logged on or not
Configure for: Windows Server 2022
Triggers Tab:
Begin the task: At statup
[ ] Stop task if it runs longer than: ....
[x] Enabled
Actions Tab:
Start a program
Program/script: "C:\Jenkins\MountS3Bucket.bat" - note that this is the exact batch script that I run using double click
Start in: "C:\Jenkins" - I have tried both with this option and without this option, same result
Conditions Tab:
All boxes are unchecked
Settings Tab:
[x] Allow task to be run on demand
[x] If the running task does not end when requested, force it to stop
If the task is already running, then the follow rule applies: "Do not start a new instance"

I force the task to run by right clicking it and selecting "Run"
The task shows up in task manager the same way both times. I go to the "Details" tab, enable the command line column, and check it. It is the exact same "User name" and "Command Line" when I run it both ways.

The only difference I can see is that the log file when it works through double clicking the batch script has the line "The service rclone has been started." and the Task Scheduler run does not have this line. I feel like I'm going a little crazy and wanted to see if anyone else has seen this issue or if I have possibly uncovered a bug of some sort.

Thanks for any help, it is appreciated.

Edit: [REDACTED3] is a truncated part of the string [REDACTED2]

try:

--no-console

Running in background

Also running task as Administrator will make drive invisible to all users - not sure this is what you want:)

User-account

And read this to do this properly:

Mount command built-in service integration

In general rclone has quite good documentation where you can find many answers

The log indicated the mount succeeded and made the S: drive.

So the mount is working, you just can't see it. Check out some of the links above for more info.

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