Setting up watches.
Watches established.
CREATE dum.txt
OPEN dum.txt
MODIFY dum.txt
CLOSE_WRITE:CLOSE dum.txt
MOVED_FROM dum.txt (if that was a temporary name)
MOVED_TO dum2.txt
监视“rsync”的脚本:
#!/bin/sh
##########################################################################################################
### $Id: OS_Admin__partitionMirror_Monitor.sh,v 1.3 2022/08/05 03:46:55 root Exp root $
###
### This script is intended to perform an ongoing scan to report when an active RSYNC backup process terminates.
##########################################################################################################
redON="\033[91;1m"
redOFF="\033[0m"
greenON="\033[92;1m"
greenOFF="\033[0m"
cyanON="\033[96;1m"
cyanOFF="\033[0m"
italicON="\033[3m"
italicOFF="\033[0m"
yellowON="\033[93;1m"
yellowOFF="\033[0m"
. $Oasis/bin/INCLUDES__TerminalEscape_SGR.bh
BASE=`basename "$0" ".sh" `
TMP="/tmp/tmp.${BASE}.$$"
date | awk '{ printf("\n\t %s\n\n", $0 ) ; }'
if [ "$1" = "--snapshots" ]
then
SNAP=1
else
SNAP=0
fi
rm -f ${TMP}
ps -ef 2>&1 | grep -v grep | grep rsync | sort -r >${TMP}
if [ ! -s ${TMP} ]
then
echo "\t RSYNC process is ${redON}not${redOFF} running (or has already ${greenON}terminated${greenOFF}).\n"
exit 0
fi
awk '{ print $2 }' <${TMP} >${TMP}.pid
awk '{ printf("%s|%s\n", $3, $2) }' <${TMP} >${TMP}.ppid
for pid in `cut -f1 -d\| ${TMP}.ppid `
do
PPID=`grep ${pid} ${TMP}.pid `
PID=`grep '^'${pid} ${TMP}.ppid | cut -f2 -d\| `
PRNT=`grep '^'${pid} ${TMP}.ppid | cut -f1 -d\| `
if [ \( -n "${PPID}" \) -a \( "${PRNT}" -ne 1 \) ]
then
descr="child"
echo "\t PID ${PID} is RSYNC ${cyanON}${italicON}${descr}${italicOFF}${cyanOFF} process ..."
else
descr="MASTER"
echo "\t PID ${PID} is RSYNC ${yellowON}${descr}${yellowOFF} process ..."
fi
done
getRsyncProcessStatus()
{
testor=`ps -ef 2>&1 | awk -v THIS="${PID}" '{ if( $2 == THIS ){ print $0 } ; }' `
MODE=`echo "${testor}" |
awk '{ if( $NF ~ /^[/]DB001_F?[/]/ ){ print "2" }else{ print "1" } ; }' 2>>/dev/null `
}
getRsyncProcessStatus
if [ ${MODE} -eq 2 ]
then
echo "\t RSYNC restore process under way ..."
INTERVAL=60
else
echo "\t RSYNC backup process under way ..."
INTERVAL=10
fi
if [ -n "${testor}" ]
then
echo "\n\t ${testor}\n" | sed 's+--+\n\t\t\t\t--+g' | awk '{
rLOC=index($0,"rsync") ;
if( rLOC != 0 ){
sBeg=sprintf("%s", substr($0,1,rLOC-1) ) ;
sEnd=sprintf("%s", substr($0,rLOC+5) ) ;
sMid="\033[91;1mrsync\033[0m" ;
printf("%s%s%s\n", sBeg, sMid, sEnd) ;
}else{
pLOC=index($0,"/DB001_") ;
if( pLOC != 0 ){
sBeg=sprintf("%s", substr($0,1,pLOC-1) ) ;
sEnd=sprintf("%s", substr($0,pLOC) ) ;
printf("%s\033[1m\033[93;1m%s\033[0m\n", sBeg, sEnd) ;
}else{
print $0 ;
} ;
} ;
}'
echo "\n\t Scanning at ${INTERVAL} second intervals ..."
test ${SNAP} -eq 1 || echo "\t \c"
fi
if [ ${SNAP} -eq 1 ]
then
while true
do
getRsyncProcessStatus
if [ -z "${testor}" ]
then
echo "\n\n\t RSYNC process (# ${PID}) has ${greenON}completed${greenOFF}.\n"
date | awk '{ printf("\t %s\n\n", $0 ) ; }'
exit 0
fi
jobLog=`ls -tr /site/Z_backup.*.err | tail -1 `
echo "\t `tail -1 ${jobLog}`"
sleep ${INTERVAL}
done 2>&1 | uniq
else
while true
do
getRsyncProcessStatus
if [ -z "${testor}" ]
then
echo "\n\n\t RSYNC process (# ${PID}) has ${greenON}completed${greenOFF}.\n"
date | awk '{ printf("\t %s\n\n", $0 ) ; }'
exit 0
fi
echo ".\c"
sleep ${INTERVAL}
done
fi
2条答案
按热度按时间nxowjjhe1#
如果安装了lsof(列出打开的文件),您可以尝试
lsof | grep tar
查看它是否仍在解压缩。4dbbbstv2#
如果要确保文件传输的完整性,最好的方法是将“rsync”与适当的选项结合使用。* 否则,需要在源和拷贝上分别执行校验和,以进行比较并确认它们是否相同 *。命令格式为
如果您尝试确认下载进程是否仍在运行,则在“ps”报告中搜索已知进程将确认该进程仍在运行。根据需要,命令格式为
如果您想要监控目标目录(* 为该下载进程唯一保留 *),以获得 * 与文件相关的操作系统操作 * 的特定洞察力,您可以使用“inotifywait”实用程序来完成此操作,如果您使用了正确的选项,该实用程序还将向您报告临时和永久文件名。
输出如下所示:
监视“rsync”的脚本:
脚本运行时终端会话的快照: