#/bin/bash
# autuor: ChiWeiming
# version: v1
# date: 2024-03-27
<<COMMAND
針對某個目錄,該目錄下有數百個子目錄,
比如 /data/att/chiweiming /data/att/linux
然後再深入一層是以日期命名的目錄,比如 /data/att/linux/20240324,每天都會生成一個日期新目錄,由於磁碟空間快滿了,所以需要講老檔案(一年以前的)挪到另一個目錄 /data1/att 下
示例: mv /data/att/linux/20240324 /data1/att/linux/20240324
挪完之後,還需要做軟連結
ln -s /data1/att/linux/20240324 /data/att/linux/20240324
需要有日誌資訊
COMMAND
function main() {
cd data/att
for dir in $(ls)
do
for subdir in $(find ${dir} -maxdepth 1 -type d)
do
rsync -aR ${subdir}/ /tmp/att/
if (( $? == 0 )); then
rm -rf ${subdir}
echo "${subdir} move successful"
ln -s /tmp/att/${subdir} data/att/${subdir} && echo "software link create successful"
echo ""
fi
done
done
}
main &> /tmp/move_old_data_$(date +%F).log
shell practice 05
相關文章
- shell practice 04
- shell practice 06
- shell practice 03
- shell practice 07
- Practice
- airflow practiceAI
- scientifically practice DP
- 05 shell程式設計之正規表示式程式設計
- shell筆記---2008-06-05筆記
- 05 Shell read讀取控制檯輸入
- Practice| 流程控制
- Best Practice in Writing
- 《前端運維》一、Linux基礎--05Shell運算子前端運維Linux
- “Docker Practice”讀書筆記Docker筆記
- yolov5s ncnn practiceYOLOCNN
- Spring Boot In Practice (0):基礎Spring Boot
- css best practice for big team and projectCSSProject
- shell筆記二---2008-06-05 下千17:31始筆記
- linux Shell 命令列-05-test 檢查某個條件是否成立Linux命令列
- Oracle 12.2 RAC on Linux Best Practice DocumentationOracleLinux
- A+B for Input-Output Practice (IV) (sdut oj)
- Practice5.1 測試與封裝5.1封裝
- 05
- Practice - iOS 專案持續整合實踐(一)iOS
- Practice – iOS 專案持續整合實踐(一)iOS
- Spring Boot In Practice (1):Redis快取實戰Spring BootRedis快取
- webpack-best-practice-最佳實踐-部署生產Web
- HDOJ 1094 A+B for Input-Output Practice (VI)
- Operating Systems: Principles and Practice 2nd ed. Edition
- java 05Java
- Oracle GoldenGate Best Practice - sample parameter files (文件 ID 1321696.1)OracleGo
- 任務05
- 05、springSpring
- 衝刺05
- 05 函式函式
- day05
- 05事務
- 樹洞05