-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.sh
37 lines (37 loc) · 1.25 KB
/
script.sh
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
27
28
29
30
31
32
33
34
35
36
37
#!/usr/local/bin/bash
cd /app/source
echo "-----------------------------------------------------------"
echo "MOVER has been started and is watching the source directory"
echo "-----------------------------------------------------------"
echo " TZ = ${TZ}"
echo " PATTERN = ${PATTERN}"
echo " INTERVAL = ${INTERVAL}"
echo "-----------------------------------------------------------"
while true
do
for ITEM in ${PATTERN}
do
if [ -e "${ITEM}" ]
then
LOG=/app/logs/$(date -I).log
DATETIME=$(date -R)
TIMESTAMP=$(date +"%Y%m%d%H%M%S")
if [ ! -f ${LOG} ]
then
touch ${LOG}
echo "A new log file has been created: ${LOG}"
echo "-----------------------------------------------------------"
fi
echo "${DATETIME}" |& tee -a ${LOG}
echo "'${ITEM}' has been found in the source directory" |& tee -a ${LOG}
if [ -e "/app/target/${ITEM}" ]
then
echo "'${ITEM}' already exists in the target directory" |& tee -a ${LOG}
mv -v -f "/app/target/${ITEM}" "/app/target/${ITEM}_${TIMESTAMP}" |& tee -a ${LOG}
fi
mv -v -f "${ITEM}" /app/target/ |& tee -a ${LOG}
echo "-----------------------------------------------------------" |& tee -a ${LOG}
fi
done
sleep ${INTERVAL}
done