Centos7.4 用shell創建以日期爲名的多級文件夾

腳本如下:

currenttime=$(date +%Y%m%d%H%M%S);
echo "current time $currenttime";

currentyear=$(date +%Y);
echo "current year:$currentyear";

currentmonth=$(date +%m);
echo "current month:$currentmonth";

currentday=$(date +%d);
echo "current day:$currentday";

hostname=`hostname`;
echo "this is hostname:$hostname";
path= "/cloud/log/$currentyear/$currentmonth/$currentday"
if [ -d "/cloud/log/$currentyear/$currentmonth/$currentday/"  ];then
    echo "the dir[/cloud/log/$currentyear/$currentmonth/$currentday/ ] is exit"
else
    mkdir -p /cloud/log/$currentyear/$currentmonth/$currentday/
fi

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章