脚本如下:
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