File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,13 @@ A docker image for nginx, while mounting ftp as a local folder
99## Envrionment
1010
1111- FTP_SERVER: server ip
12- - FTP_USER: username
12+ - FTP_USER: username
1313- FTP_PASSWORD: password
1414- FTP_REMOTE_DIR: ftp remove directory
1515- FTP_MOUNT_POINT: mount folder in container
1616- FTP_RETAIN_DAYS: The file retention days are optional. If set, it will regularly clean up the files in ftp.
1717
18- ## docker-compose
18+ ## docker-compose
1919
2020``` yaml
2121services :
@@ -31,7 +31,7 @@ services:
3131 - FTP_PASSWORD=123456
3232 - FTP_SERVER=192.168.5.112
3333 # - FTP_REMOTE_DIR=/ht 路径必须以 / 开头
34- - FTP_RETAIN_DAYS=7
34+ - FTP_RETAIN_DAYS=7 # 以当前时间2025-07-28 16:21:30为例,当 FTP_RETAIN_DAYS 为1时,会删除 2025-07-27 16:21:30前的数据,即仅保留24小时的数据
3535
3636 ftp :
3737 image : dotkevinwong/vsftpd-arm
@@ -44,9 +44,9 @@ services:
4444 - PASV_ADDRESS=192.168.5.112
4545 - LOG_STDOUT=YES
4646 ports :
47- - ' 20:20/tcp'
48- - ' 21:21/tcp'
49- - ' 21100-21110:21100-21110/tcp'
47+ - " 20:20/tcp"
48+ - " 21:21/tcp"
49+ - " 21100-21110:21100-21110/tcp"
5050 volumes :
51- - ' /tmp/ftp:/home/vsftpd'
51+ - " /tmp/ftp:/home/vsftpd"
5252` ` `
Original file line number Diff line number Diff line change 77echo " Starting cleanup of files older than $FTP_RETAIN_DAYS days."
88
99# 删除早于 FTP_RETAIN_DAYS 天的文件
10- find /mnt/ftp -type f -mtime +$FTP_RETAIN_DAYS -delete
10+ n=$(( FTP_RETAIN_DAYS+ 1 ))
11+ dt=$( date -d " 1 day ago $( date -d ' 1 second ago' +' %H:%M:%S' ) " +" %Y-%m-%d %H:%M:%S" )
12+ find /mnt/ftp -type f ! -newermt " $dt " -delete
1113
1214# 打印清理完成的日志
13- echo " Cleanup completed."
15+ echo " Cleanup completed."
You can’t perform that action at this time.
0 commit comments