#/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 03
- shell practice 04
- shell practice 06
- shell practice 07
- Practice
- airflow practiceAI
- 05 Shell read讀取控制檯輸入
- 05 shell程式設計之正規表示式程式設計
- scientifically practice DP
- Practice| 流程控制
- 《前端運維》一、Linux基礎--05Shell運算子前端運維Linux
- Vegetables need more practice.
- [#181024][PAT Practice] A+B FormatORM
- yolov5s ncnn practiceYOLOCNN
- linux Shell 命令列-05-test 檢查某個條件是否成立Linux命令列
- Oracle 12.2 RAC on Linux Best Practice DocumentationOracleLinux
- 1003 我要通過!| PAT (Basic Level) Practice
- SAP S4HANA LTMC Practice - the first shot!
- <OFFER05> 05_ReplaceSpaces
- Practice – iOS 專案持續整合實踐(一)iOS
- Practice - iOS 專案持續整合實踐(一)iOS
- Operating Systems: Principles and Practice 2nd ed. Edition
- The practice of high-performance graph computing system Plato in Nebula GraphORM
- PAT (Advanced Level) Practice 1149 Dangerous Goods Packaging (25分)Go
- 05
- Shell:子shell概念
- 05、springSpring
- java 05Java
- SDNU_ACM_ICPC_2021_Winter_Practice_4th [個人賽]ACM
- PAT (Basic Level) Practice (中文)-1009-說反話 (20分)
- shell——shell輸入輸出
- Software-Defined Networking and Security From Theory to Practice (Data-Enabled Engineering).pdf ...
- 打字大師3-盲打實踐:Master of Typing 3 - Practice for MacASTMac
- Shell程式設計-11-子Shell和Shell巢狀程式設計巢狀
- Shell
- 2024/05/27
- 2024/05/16
- JSON 物件——05JSON物件