Windows 8.1 任务计划程序不会在未登录的情况下执行 Rsync/SSH [英] Windows 8.1 Task Scheduler Won't Execute Rsync/SSH Without being Logged On
问题描述
我已经在 Windows 8.1 中创建并安排了一个批处理文件(通过 SSH 隧道执行 rsync 异地备份)并且我可以运行它:
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:
- user=me(我是管理员组的成员)
- 无论是否登录都运行
- 以最高权限运行
我可以在任务管理器中看到 rsync.exe 和 ssh.exe 正在运行,因此它必须挂在 rsync/ssh 调用上.这让我相信问题在于,即使我已经明确设置了用户名,某些东西并没有真的像我一样运行?(侧边栏:我也试过以 SYSTEM 用户身份运行任务 - 也没有运气)
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!)
推荐答案
当我在 Windows Server 2012 R2 上遇到此问题时,我发现 SSH.exe 在尝试创建 known_hosts 文件时遇到权限错误,尽管任务正在运行具有管理员凭据和最高权限.
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.
解决方案是使用 UserKnownHostsFile
SSH 选项指向用户现有的 known_hosts 文件:
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
这篇关于Windows 8.1 任务计划程序不会在未登录的情况下执行 Rsync/SSH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!