[英]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.