简体   繁体   中英

Best way to collect logs from a remote server

I need to run some commands on some remote Solaris/Linux servers and collect their output in a log file on my local server.

Currently, I'm using a simple Expect script, residing on the local server to fire the commands on the target system. I then redirect the output of the expect script to a log file, like this,

/usr/local/bin/expect script.exp >> logfile.txt

However, this is proving to be very unreliable as the connection to the server fluctuates a lot, leading to incomplete logs and hung scripts.

Is there a better and more reliable way to go about this task?

I have implemented fedorqui's answer,

  • Created a (shell) script that runs the required commands on the target servers.
  • Deployed this script to all servers.
  • Executed this script via expect, from my local (central) server.
  • Finally collected logs individually from each server after successful completion, and processed them.

The solution has been working fine without a glitch till now.

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