From 9d7a4096f9289f019da5e9c3b6986474b2e6f6ea Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Wed, 20 Mar 2019 23:33:37 +0000 Subject: [PATCH] Pipe into second find directly --- archivebot-list-stuck-requests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archivebot-list-stuck-requests b/archivebot-list-stuck-requests index e15b38d..0f71688 100755 --- a/archivebot-list-stuck-requests +++ b/archivebot-list-stuck-requests @@ -1,3 +1,3 @@ #!/bin/bash # For each ArchiveBot job running on the machine, list requests that are stuck, i.e. older than 6 hours -ps -C wpull --format 'pid,cmd' --no-headers | sed 's,^\s*,,; s,\s*/usr/bin/python3.*/data/[^/]\+/\([0-9a-z]\+\)/wpull\.log.*$, \1,' | while read -r pid jobid; do echo "$jobid (PID $pid)"; fs=$(find /proc/${pid}/fd -lname '*/tmp-wpull-warcsesreq-*' -printf '%l\n' 2> >(grep -v ': No such file or directory$' >&2)); fs=$(find ${fs} -mmin +360); if [[ "${fs}" ]]; then for f in ${fs}; do mtime=$(date --date="@$(stat -c '%Y' ${f})" '+%Y-%m-%d %H:%M:%S %Z'); grep ^Host ${f} | while read -r outline; do echo "${mtime} ${f} ${outline}"; done; done | sort; else echo 'None'; fi; echo; done +ps -C wpull --format 'pid,cmd' --no-headers | sed 's,^\s*,,; s,\s*/usr/bin/python3.*/data/[^/]\+/\([0-9a-z]\+\)/wpull\.log.*$, \1,' | while read -r pid jobid; do echo "$jobid (PID $pid)"; find /proc/${pid}/fd -lname '*/tmp-wpull-warcsesreq-*' -printf "%l\0" | xargs -0 bash -c 'find "$@" -mmin +360 -printf "%TY-%Tm-%Td %TH:%TM:%TS %TZ\0%p\0"' bash 2> >(grep -v ': No such file or directory$' >&2) | while IFS= read -r -d '' mtime; IFS= read -r -d '' filename; do grep ^Host "${filename}" | while read -r outline; do echo "${mtime} ${filename} ${outline}"; done; done | sort | sed 's,\.[0-9]\+,,' | grep ^ || echo 'None'; echo; done