简体   繁体   中英

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 server has enabled both scp and 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. Also need to download the log file to the location where the bat file is executing from. 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. 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. If I were you I'd either install cygwin or install WSL, and use a unix script to use scp to copy it down. You can even use cron to automate it if you want. Then your local windows machine will be close enough to a UNIX machine.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM