I've created and scheduled a batch file in Windows 8.1 (to perform rsync offsite backups through an SSH tunnel) and I can run it:
... but when I'm not logged on, it just sits at "Running" even though I've set it as follows:
I can see in Task Manager that rsync.exe and ssh.exe are running, so it must be hanging on the rsync/ssh call. That leads me to believe the problem is that, even though I've explicitly set the user name, something isn't really running as me? (sidebar: I've also tried running the task as SYSTEM user - no luck there either)
The command I'm issuing looks like this:
rsync --archive --verbose --human-readable --hard-links --delete --exclude '*.log' --exclude '*log*.*' -e "%CWRSYNCBIN%\ssh -p 22103 -i C:\Users\test\.ssh\id_rsa" "/cygdrive/c/Users/test/Downloads" admin@1.2.3.4:/path/to/remote 1> %REPORTLOG% 2> %ERRORLOG%
Any ideas? (thanks!)
This seems to be problem with home directory and non-interactive environment in scheduled jobs in newer Windows version (starting from Server 2008 and Vista?). I find it in few discussions, but with not much info to solve it:
My solution was:
SET HOME=D:\\CWRSYNC\\HOME
),
@ECHO OFF
SETLOCAL
SET CWRSYNCHOME=D:\CWRSYNC
SET HOME=D:\CWRSYNC\HOME
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%;%PATH%
rsync.exe -rtvz --delete /cygdrive/b/ user@192.168.1.2:/volume1/NetBackup/ >> D://nas-backup-log.txt
When I experienced this problem on Windows Server 2012 R2, I found SSH.exe was experiencing a permissions error when attempting to create a known_hosts file, despite the task running with an admin's credentials and with highest privileges.
The solution was to point to the user's existing known_hosts file using the UserKnownHostsFile
SSH option:
rsync -e "ssh -i sshkey -o UserKnownHostsFile path/to/known_hosts" source dest
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.