标签:success message his clean 失败 fail cannot span directory
1 #!/bin/bash 2 #清除日志脚本 3 LOG_DIR=/var/log 4 ROOT_UID=0 #用户id为0的 ,即为root 5 6 if [ "$UID" -ne "$ROOT_UID" ] #如果用户不是root,则不执行,退出 7 then 8 echo "Must be root run this sript!" 9 exit 1 10 fi 11 12 cd $LOG_DIR || { #如果切换目录失败,退出8i 13 echo "Cannot change to necessary directory!" 14 exit 1 15 } 16 17 > messages && { #清空日志 18 echo "Logs cleaned up success!" 19 exit 0 #返回0表示成功,1表示失败 20 } 21 22 echo "Logs cleaned up fail..." 23 exit 1
标签:success message his clean 失败 fail cannot span directory
原文地址:https://www.cnblogs.com/zhoul/p/9926205.html