Skip to content
  • This project
    • Loading...
  • Sign in

谢俊文 / Job.slice.push_cdn

Go to a project
Toggle navigation
Toggle navigation pinning
  • Projects
  • Groups
  • Snippets
  • Help
  • Project
  • Activity
  • Repository
  • Pipelines
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • Network
  • Create a new issue
  • Builds
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Network
  • Compare
  • Branches
  • Tags
Switch branch/tag
  • Job.slice.push_cdn
  • push
  • keepfree.sh
  • 谢俊文's avatar
    Initial commit · 8db33c07
    8db33c07 Browse Files
    谢俊文 authored 2020-02-18 10:38:51 +0800
keepfree.sh 338 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/bin/bash

#保留文件数
ReservedNum=7
FileDir="/data/bak /data/bak2"
date=$(date "+%Y%m%d-%H%M%S")


for i in $FileDir
do
FileNum=$(ls -l $i|grep ^d |wc -l)
	while(( $FileNum > $ReservedNum))
	do
    		OldFile=$(ls -rt $i| head -1)
    		echo  $date "Delete File:"$OldFile
    		rm -rf $i/$OldFile
    		let "FileNum--"
	done

done