feat: sync datas
This commit is contained in:
24
cron.sh
Normal file
24
cron.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
LOG_FILE="/var/log/qvyun.sync.log"
|
||||
MAX_SIZE=$((10 * 1024 * 1024)) # 10MB in bytes
|
||||
|
||||
# Clean up old log files
|
||||
find "$(dirname "$LOG_FILE")" -name "$(basename "$LOG_FILE")*" -type f -mtime +7 -delete
|
||||
|
||||
# Check and rotate log if needed
|
||||
if [ -f "$LOG_FILE" ]; then
|
||||
FILE_SIZE=$(stat -f%z "$LOG_FILE")
|
||||
if [ $FILE_SIZE -gt $MAX_SIZE ]; then
|
||||
mv "$LOG_FILE" "${LOG_FILE}.$(date +%Y%m%d-%H%M%S)"
|
||||
fi
|
||||
fi
|
||||
|
||||
start_time=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
echo "Start sync at $start_time" >>"$LOG_FILE"
|
||||
|
||||
qvyun --config /usr/local/etc/qvyun.toml tasks discover --from /mnt/ypl/publish/ --to /mnt/ypl/publish/processed/1 2>&1 >>"$LOG_FILE"
|
||||
rsync -avh --progress /mnt/ypl/publish/processed/ server.ali.bj.01:/data 2>&1 >>"$LOG_FILE"
|
||||
|
||||
end_time=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
echo "End sync at $end_time" >>"$LOG_FILE"
|
||||
Reference in New Issue
Block a user