[英]Windows 8.1 Task Scheduler Won't Execute Rsync/SSH Without being Logged On
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: 我已经在Windows 8.1中创建并计划了一个批处理文件(以通过SSH隧道执行rsync异地备份),并且可以运行它:
... 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. 我可以在任务管理器中看到rsync.exe和ssh.exe正在运行,因此它必须挂在rsync / ssh调用上。 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)
(侧边栏:我也尝试过以SYSTEM用户身份运行任务-那里也没有运气)
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?). 这似乎是主目录和非交互环境在较新的Windows版本(从Server 2008和Vista开始)中的计划作业中的问题。 I find it in few discussions, but with not much info to solve it:
我在很少的讨论中找到了它,但是没有足够的信息来解决它:
My solution was: 我的解决方案是:
SET HOME=D:\\CWRSYNC\\HOME
), 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. 当我在Windows Server 2012 R2上遇到此问题时,我发现SSH.exe在尝试创建known_hosts文件时遇到权限错误,尽管该任务以管理员的凭据和最高权限运行。
The solution was to point to the user's existing known_hosts file using the UserKnownHostsFile
SSH option: 解决方案是使用
UserKnownHostsFile
SSH选项指向用户现有的known_hosts文件:
rsync -e "ssh -i sshkey -o UserKnownHostsFile path/to/known_hosts" source dest
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.