lsof
должен сделать задание. Попросите, чтобы это дало Вам вывод машины-parseable с -F
опция.
lsof -n -i @${hostname}:${port} -F nT | grep '^TST=ESTABLISHED$'
Если Вам нужно больше информации:
lsof -n -i -F nT | awk '
function host_port(s, a) {
match(s, /:[^:]*$/);
a["host"] = substr(s, 1, RSTART-1);
a["port"] = substr(s, RSTART+1);
}
sub(/^p/,"") {pid = $0}
sub(/^n/,"") {
split($0, endpoints, "->");
host_port(endpoints[1], from);
host_port(endpoints[2], to);
}
/^TST=ESTABLISHED$/ {
print "Established from", from["host"] ":" from["port"],
"to", to["host"] ":" to["port"]
}
'
Можно использовать lftp
для этого, используя mirror
команда. Вот надрез из страницы справочника:
mirror [OPTS] [source [target]]
Mirror specified source directory to local target directory. If target
directory ends with a slash, the source base name is appended to
target directory name. Source and/or target can be URLs pointing to
directories.
[cut...]
-N, --newer-than=SPEC download only files newer than specified time
--on-change=CMD execute the command if anything has been changed
--older-than=SPEC download only files older than specified time
[...]
Определенно взгляните на руководство, поскольку существует действительно много полезных опций к mirror
- как --allow-chown
, --allow-suid
или --parallel[=N]
например. Lftp также работает с другими протоколами доступа, как sftp
, fish
или http(s)
.
Вы могли попытаться монтировать его как использование файловой системы curlftpfs
.
Затем использование копии find
.
например:
mkdir /tmp/mountpoint
curlftpfs ftp://example.com/ /tmp/mountpoint/
cd /tmp/mountpoint
find -mtime +90 -exec cp {} /dest/path/ \;
Я подозреваю, что лучшие решения существуют.