1

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/ root@192.168.158.35://mnt/share/Bilder/Normal
rsync -rtv -e "ssh -i /home/fernien/id_rsa" /mnt/g/Bilder\ Editiert/ root@192.168.158.35://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
    Do you mean `cd /d c:\scripts` in the second line of your batch file? – FedonKadifeli Jul 18 '19 at 13:13
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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.