-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path1c_tech_log_compress.sh
More file actions
executable file
·26 lines (21 loc) · 1.02 KB
/
1c_tech_log_compress.sh
File metadata and controls
executable file
·26 lines (21 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
#
# Эксплуатация 1С Предприятия 8.3: Сжатие и удаление файлов ТЖ
#
# (c) 2020, Алексей Ю. Федотов
#
# Email: fedotov@kaminsoft.ru
#
ARCH_DIR="/iRR/archive/tech_logs"
cd ${ARCH_DIR} || exit 1
# Compress and remove log files most then one day oldest per Nodes
for NODE_NAME in $( find ./ -maxdepth 1 -type d | sed -re 's/^\.\///; s/(.*)\-[^\-]+/\1/' | grep -vPe '^$' | sort -u ); do
for ARCH_DATE in $(find "./${NODE_NAME}*" -mtime +1 -daystart -name '*.log' -printf "%f\n" | sed -re "s/(^[0-9]{6}).*/\1/" | sort -u); do
tar czf ${NODE_NAME}-${ARCH_DATE}.tgz --remove-files $(find ${NODE_NAME}*/ -name "${ARCH_DATE}*.log") > /dev/null
touch ${NODE_NAME}-${ARCH_DATE}.tgz -t $(date -d "${ARCH_DATE} next day" +%m%d%H%M)
done
done
# Удаление файлов старше 30 дней
find ${ARCH_DIR} -mtime +30 -name '*.tgz' -type f -daystart -delete
# Удаление пустых каталогов
find ${ARCH_DIR} -type d -empty -delete