# Problem using sync command with Windows Task Scheduler

**URL:** <https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057>\
**Category:** Help and Support\
**Created:** [July 17, 2023, 6:17pm UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057 "2023-07-17T18:17:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![lAlterado](https://forum.rclone.org/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lAlterado](https://forum.rclone.org/u/lAlterado)\
**Post date:** [July 17, 2023, 6:17pm UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057/1 "2023-07-17T18:17:27Z")

</div>

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

When i try to execute a simple sync command between a local folder and a folder on OneDrive (crypt remote), it seems to run normally as expected on command line. But when it comes to Windows Task Scheduler (to automate this backup job), the below command seems not be executed. I copied the exact same command that i've checked working on CLI, pasted it to the task action parammeters (with rclone.exe as the executable), and it just doesn't execute, as no log file is generated and the destination is not synced (no test files created on source are synced with destination).

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

rclone v1.62.2

- os/version: Microsoft Windows 10 Home Single Language 22H2 (64 bit)
- os/kernel: 10.0.19045.3208 Build 19045.3208.3208 (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)

OneDrive

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

sync "D:\user" ode:Desktop/user --checksum -P --no-console --stats-log-level NOTICE --log-file=D:/user/Documents/rclone/"log update %date:~0,2%-%date:~3,2%-%date:~6,4% %time:~0,2%-%time:~3,2%-%time:~6,2%.log" -vv --drive-use-trash

#### The rclone config contents with secrets removed.

#### A log from the command with the `-vv` flag

There's no log file, it seems the command is not executed

---

<div class="post-metadata">

**Author:** ![asdffdsa](https://forum.rclone.org/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@asdffdsa](https://forum.rclone.org/u/asdffdsa)\
**Post date:** [July 17, 2023, 6:27pm UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057/2 "2023-07-17T18:27:24Z")

</div>

welcome to the forum,

might check out this, need to hardcode all paths including config file and location of `rclone.exe`

> [@Mount point goes away when I close command prompt app](https://forum.rclone.org/t/mount-point-goes-away-when-i-close-command-prompt-app/40024/5):
>
> task scheduler much easier to use than nssm. when running as a service need to: use a rclone debug log file hardcode full paths, c:\path\to\rclone.exe lsd remote: --config=c:\path\to\rclone.conf --log-file=c:\path\to\rclone.log strange that you are running rclone as a service and still rclone is visible. [image]

`--log-file=D:/user/Documents/rclone/"log`  
perhaps cut and paste problem?

maybe, if you need environment variables, might try `cmd /c c:\path\to\rclone.exe sync ...`  
or put run a command inside a .cmd and run the .cmd  
something like this

```auto
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I
set datetime=rclone.%datetime:~0,4%%datetime:~4,2%%datetime:~6,2%.%datetime:~8,2%%datetime:~10,2%%datetime:~12,2%
c:\path\to\rclone.exe sync ... --log-file=d:\user\documents\rclone\%datetime%.log
```

---

<div class="post-metadata">

**Author:** ![bstrmbrg](https://forum.rclone.org/letter_avatar_proxy/v4/letter/b/ba8739/32.png) [@bstrmbrg](https://forum.rclone.org/u/bstrmbrg)\
**Post date:** [July 17, 2023, 9:59pm UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057/3 "2023-07-17T21:59:24Z")

</div>

Hi,

> [@asdffdsa](#):
>
> might check out this, need to hardcode all paths including config file and location of `rclone.exe`

Like asdffdsa said, you need to specify the full path, for example:

```auto
c:\rclone\rclone.exe sync ...

```

Also, I'm pretty sure you should remove the " from the file name of the log file. If I do

```auto
echo "log update %date:~0,2%-%date:~3,2%-%date:~6,4% %time:~0,2%-%time:~3,2%-%time:~6,2%.log"

```

It includes the " and that is not valid in a Windows file name. Even when (especially) your rclone command fails, it should generate a log file. If it doesn't, most likely you aren't successfully running the exe

---

<div class="post-metadata">

**Author:** ![lAlterado](https://forum.rclone.org/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lAlterado](https://forum.rclone.org/u/lAlterado)\
**Post date:** [July 17, 2023, 11:45pm UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057/4 "2023-07-17T23:45:32Z")

</div>

Hey! Thanks for the answer.  
Just to be sure if i understood correctly, when setting up the action part on windows task scheduler, i need to select the rclone.exe and also specify the full path of rclone on my pc before the command itself on parameters?  
I mean, here where the arrow is poiting:

 ![image](https://forum.rclone.org/uploads/default/original/2X/d/dfe762d29a05c1c2dc99fd57465ff14850dd65aa.png)

I need to write:  
`full/path/to/rclone.exe sync "D:\user" ode:Desktop/user --checksum -P --no-console --stats-log-level NOTICE --log-file=D:/user/Documents/rclone/log update %date:~0,2%-%date:~3,2%-%date:~6,4% %time:~0,2%-%time:~3,2%-%time:~6,2%.log -vv --drive-use-trash`

That's what you are saying? Or i missed something?

---

<div class="post-metadata">

**Author:** ![bstrmbrg](https://forum.rclone.org/letter_avatar_proxy/v4/letter/b/ba8739/32.png) [@bstrmbrg](https://forum.rclone.org/u/bstrmbrg)\
**Post date:** [July 18, 2023, 2:53am UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057/5 "2023-07-18T02:53:15Z")

</div>

Something like that, yeah. But you can't have spaces in the path, I'd replace them with underscores. Or encapsulate the whole path in quotation marks, like:

```auto
--log-file="D:/user/Documents/rclone/log update %date:~0,2%-%date:~3,2%-%date:~6,4% %time:~0,2%-%time:~3,2%-%time:~6,2%.log"

```

I'm more familiar with linux so I'm not 100% sure how command arguments work in Task Scheduler, since you are using environment variables you might need to

> [@asdffdsa](#):
>
> maybe, if you need environment variables, might try `cmd /c c:\path\to\rclone.exe sync ...`

If you want a more detailed log you can use

```auto
--log-level=DEBUG

```

---

<div class="post-metadata">

**Author:** ![lAlterado](https://forum.rclone.org/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lAlterado](https://forum.rclone.org/u/lAlterado)\
**Post date:** [July 26, 2023, 1:18pm UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057/6 "2023-07-26T13:18:29Z")

</div>

I'm still having issues... Tried everything i could imagine, but nothing solves the problem. The command runs as expected when in CMD, but when it comes to the windows task manager, nothing happens. The log file isn't generated as well.  
Its incredible, i did everything exactly the same this guy said here [How to setup periodic sync in Windows 10 - #2 by asdffdsa](https://forum.rclone.org/t/how-to-setup-periodic-sync-in-windows-10/21192/2)

 ![image](https://forum.rclone.org/uploads/default/original/2X/a/a859d12f4486e9901d49b96aac52ed80b46a36f8.png)  
 ![image](https://forum.rclone.org/uploads/default/original/2X/f/fba86a7ee78f719e3d1c8f4736ebbfb173fe859f.png)  
 ![image](https://forum.rclone.org/uploads/default/original/2X/1/171fc295ecc70d6b0e596fcfe9d62a20a698477f.png)  
 ![image](https://forum.rclone.org/uploads/default/original/2X/8/80e45dd50f0cb2b32198902404abf63917e973c9.png)  
And i just can't get this simple task done... it's so tough, don't know what else i can do. Maybe i don't have the knowledge of o.s. required to operate rclone, don't know.

---

<div class="post-metadata">

**Author:** ![asdffdsa](https://forum.rclone.org/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@asdffdsa](https://forum.rclone.org/u/asdffdsa)\
**Post date:** [July 26, 2023, 1:39pm UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057/7 "2023-07-26T13:39:18Z")

</div>

> [@lAlterado](#):
>
> i did everything exactly the same this guy

hi, i am that guy and imho, you did not do everything exactly the same.  
twice now, in this topic and in that topic, i recommended to put the command into a .cmd file.  
and run the .cmd from terminal and tasksch.

fwiw, for testing, you can run a task on the fly, without a trigger.  
for example, something like  
`C:\Windows\System32\schtasks.exe /run /tn "rclone\FileHistory back-up rclone"`

and your settings, are configured for `windows vista/2008`?

for testing, use a simple rclone command. get that working, then try more complex commands.  
for example  
`c:\users\karl\rclone.exe version --log-level=DEBUG --log-file=d:/user/documents/rclone/rclone.log`

on my system, might look like

```auto
c:\data\rclone>type doit.cmd
c:\data\rclone\rclone.exe version --log-level=DEBUG --log-file=c:\data\rclone\rclone.log

c:\data\rclone>doit.cmd

c:\data\rclone>c:\data\rclone\rclone.exe version --log-level=DEBUG --log-file=c:\data\rclone\rclone.log
rclone v1.63.0
- os/version: Microsoft Windows 11 Pro 22H2 (64 bit)
- os/kernel: 10.0.22621.1992 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.20.5
- go/linking: static
- go/tags: cmount

c:\data\rclone>type c:\data\rclone\rclone.log
2023/07/26 09:44:22 DEBUG : rclone: Version "v1.63.0" starting with parameters ["c:\\data\\rclone\\rclone.exe" "version" "--log-level=DEBUG" "--log-file=c:\\data\\rclone\\rclone.log"]
2023/07/26 09:44:22 DEBUG : rclone: Version "v1.63.0" finishing with parameters ["c:\\data\\rclone\\rclone.exe" "version" "--log-level=DEBUG" "--log-file=c:\\data\\rclone\\rclone.log"]

```

and in tasksch, for the action, use `c:\data\rclone\doit.cmd`

---

<div class="post-metadata">

**Author:** ![lAlterado](https://forum.rclone.org/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lAlterado](https://forum.rclone.org/u/lAlterado)\
**Post date:** [July 27, 2023, 5:22am UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057/8 "2023-07-27T05:22:21Z")

</div>

Hey!  
I read all the things you wrote [here](https://forum.rclone.org/t/how-to-setup-periodic-sync-in-windows-10/21192/6) and [here](https://forum.rclone.org/t/how-to-automatize-rclone/14181/21) and after following your advice to create .cmd files and execute through windows task manager, it worked out. Thank you.  
I don't know why only pasting the commands directly on the action section doesn't work, but it's fine, maybe it require some advanced o.s. knowledge i just don't have currently.  
Thank you for your reference on [cmd basics](https://ss64.com/nt/syntax.html), it seems pretty useful, i'll check it out 🙂

---

<div class="post-metadata">

**Author:** ![asdffdsa](https://forum.rclone.org/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@asdffdsa](https://forum.rclone.org/u/asdffdsa)\
**Post date:** [July 27, 2023, 1:08pm UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057/9 "2023-07-27T13:08:31Z")

</div>

good that you got it worked out.

> [@lAlterado](#):
>
> Thank you for your reference on [cmd basics](https://ss64.com/nt/syntax.html)

[https://www.nirsoft.net/utils/nircmd.html](https://www.nirsoft.net/utils/nircmd.html)  
that site has an amazing list of free command line tools

---

<div class="post-metadata">

**Author:** ![lAlterado](https://forum.rclone.org/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lAlterado](https://forum.rclone.org/u/lAlterado)\
**Post date:** [July 27, 2023, 10:01pm UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057/10 "2023-07-27T22:01:57Z")

</div>

Thank you, mate. Saved here for checking 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [August 26, 2023, 10:01pm UTC](https://forum.rclone.org/t/problem-using-sync-command-with-windows-task-scheduler/40057/11 "2023-08-26T22:01:59Z")

</div>

Closed on August 26, 2023, 10:01pm UTC

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