move log file to another device
scheduled move specific file to target directory1
2
3
4
5
6
7
8
9
10
11
12
13
# move log 1 month ago
# get date string
date=`date -d '1 month ago' +'%Y-%m-%d'`
# file name
default="/logs/common-default.log."${date}".log"
if [ -f "$default" ]; then
echo $date' move '$default' to /data0/backup' >> /logs/backup.log
`mv $default /data0/backup`
fi
crontab -e
add schedule1
10 0 * * * sh /move.sh
delete log file by function
1 |
|
delete log file by command
1 |
|
{}
is placeholder of the file be found\;
mean exec command finish
process every line in a multi-line variable
https://cloud.tencent.com/developer/ask/46222
‘crontab’ schedule
https://www.cnblogs.com/peida/archive/2013/01/08/2850483.html
‘find’ command -exec
https://blog.csdn.net/u010900754/article/details/83020378
‘find’ command useage
https://blog.csdn.net/h106140873/article/details/72874455