简体   繁体   English

自动将日志文件从远程 linux 服务器下载到 windows 服务器

[英]Automating a log file downloading from a remote linux server to a windows server

I want to download a log file daily from a linux server (/opt/logs/Reports/2022-07-19_Hourly.log) to my windows laptop.我想每天从 linux 服务器 (/opt/logs/Reports/2022-07-19_Hourly.log) 下载一个日志文件到我的 Windows 笔记本电脑。 Linux server has enabled both scp and ssh. Linux 服务器已启用 scp 和 ssh。 As im not much familiar with scripting I just need to write a small script to automate this process with a small bat file or something.由于我对脚本不太熟悉,我只需要编写一个小脚本来使用一个小的 bat 文件或其他东西来自动化这个过程。 Also need to download the log file to the location where the bat file is executing from.还需要将日志文件下载到执行 bat 文件的位置。 eg: If im inside a folder in the desktop and running the script then the log file also should download for the same folder.例如:如果我在桌面的一个文件夹中并运行脚本,那么日志文件也应该为同一个文件夹下载。 Log file location is /opt/logs/Reports/2022-07-19_Hourly.log and the date should be the yesterdays date and the script will be running in the next day.日志文件位置是/opt/logs/Reports/2022-07-19_Hourly.log,日期应该是昨天的日期,脚本将在第二天运行。 In simply the date should be changed to the previous date.简单地说,日期应更改为前一个日期。 If anyone can help me it would be great.如果有人可以帮助我,那就太好了。 Thank you.谢谢你。

使用 c#,您可以编写一个将在 Windows 系统上运行的小应用程序并使用 sftp https://www.c-sharpcorner.com/blogs/sftp-file-upload-with-c-sharp-application下载文件这是一个如何编写 sftp 客户端的示例。

Scripting in pure Windows is a pain, IMO. IMO,在纯 Windows 中编写脚本很痛苦。 If I were you I'd either install cygwin or install WSL, and use a unix script to use scp to copy it down.如果我是你,我会安装 cygwin 或安装 WSL,然后使用 unix 脚本使用 scp 将其复制下来。 You can even use cron to automate it if you want.如果你愿意,你甚至可以使用 cron 来自动化它。 Then your local windows machine will be close enough to a UNIX machine.然后,您的本地 Windows 机器将与 UNIX 机器足够接近。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将文件从Windows便携式计算机复制到Linux远程服务器 - How to copy file from Windows laptop to Linux remote server 从 windows 机器上查看远程 linux 服务器上动态生成的日志的更新 - Viewing updates of a dynamically generated log on a remote linux server from a windows machine 从远程服务器下载文件,下载完成后删除 - download file from remote server and delete after complete downloading 使用scp从远程服务器下载文件。 但是返回错误 - Downloading file using scp from a remote server. But returning error 将pscp文件从窗口服务器复制到远程linux服务器 - copy pscp a file from window server to to remote linux server 从Linux jenknins在远程Windows服务器上调用批处理命令 - From Linux jenknins call batch command on remote windows server 从Windows桌面访问远程Linux服务器的localhost:8080 - Accessing remote linux server's localhost:8080 from windows desktop 从Linux机器将mySQLdump转储到远程服务器上的已安装Windows文件夹 - mySQLdump from Linux machine to a mounted Windows folder on a remote server 无法从Windows使用Paramiko登录Linux服务器 - Not able to log into Linux server using Paramiko from Windows 如何使用 Java 将文件从 linux 服务器发送到 windows 服务器? - How to send file from linux server to windows server using Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM