2

i want to automatically sync the folder on my windows pc to my external harddrive connected to a raspberrypi. My script works and just uses rsync to copy 2 folders over.

I want to automate it via Task Scheduler but it doesn't work. I tried running it directly as a bash script from Task Scheduler and i tried another thing that came to my mind. I wrote a batch file which executes my bash script. It works when executing the batch file per hand but when i do it via Task Scheduler it doesnt work anymore and i cant figure out why since i dont have error messages or something.

I also wrote another batch file which creates a folder and executed it via Task Scheduler which worked fine. The Problem hast to be something with Task Scheduler and bash.

Any help would be much appreciated!

Bash script:

#!/bin/bash

rsync -rtv -e "ssh -i /home/fernien/id_rsa" /mnt/g/100D3300/ [email protected]://mnt/share/Bilder/Normal
rsync -rtv -e "ssh -i /home/fernien/id_rsa" /mnt/g/Bilder\ Editiert/ [email protected]://mnt/share/Bilder/Editiert

Batch file to run this script:

tried different varieties. With -c, without -c, with "./" and without.

@echo off
c:\scripts\
bash.exe -c "./sync.bash"
1
  • 1
    Do you mean `cd /d c:\scripts` in the second line of your batch file?
    – FedKad
    Commented Jul 18, 2019 at 13:13

2 Answers 2

1

Thanks to @FedonKadifeli. The Problem was in my script: This did work when executed from hand, i don't know why but it did.

@echo off
c:\scripts\
bash.exe -c "./sync.bash"

But it should look like this. After correcting it, it worked fine for me. Shouldve spent more time with batch scripting.

@echo off
c:
cd \scripts\
bash.exe -c "./sync.bash"
0

in your DOS batch script, you could change of drive and path with a one-line command thanks to cd command's /D commutator. Hence you would end up with the following :

@echo off
cd /D c:\scripts\
bash.exe -c "./sync.bash"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .