cyclists 大佬有话说 :
再次求助,SH 脚本大佬进来看看我这个是啥问题!
感谢之前帖子里的12楼大佬帮我写了个脚本,由于他工作原因,不太方便经常打扰别人。
# !/bin/bash -x
# filename:running.sh
curr_run_time=`date +%s`
phat="/var/log/rundate.log"
ni=$(date +20%y-%m-%d)
if [ ! -n "${1}" ]; then
echo "Please enter a specified value"
else
value="${1}"
if [ ! -f "${phat}" ]; then
touch "${phat}"
echo -e "1|${ni}" > "${phat}"
else
i=$(cat "${phat}" | sed ‘/^s*$/d’ | awk -F "|" ‘{ print $1 }’)
ii=$(cat "${phat}" | sed ‘/^s*$/d’ | awk -F "|" ‘{ print $2 }’)
if [ "${ii}" != "${ni}" ]; then
if [ "${i}" != "${value}" ]; then
li=$(($i+1))
echo -e "${li}|${ni}" > "${phat}"
else
bash mkdir xxx
sed -i "4s/ * /$curr_run_time/" mkdir xxx
echo -e "1|${ni}" > "${phat}"
fi
fi
fi
fi
我执行 bash running.sh 1 的时候,rundate.log里会自动写入日期,但是root根目录并没有创建 xxx 文件,把上述里的bash mkdir xxx代码替换成 bash acme.sh —renew-all ,我去acme.sh.log日志里看也没有最新执行时间。
各位热心大佬们可以帮忙看看吗?
h2o 大佬有话说 :
不就是个定期申请证书吗,用搞的这么复杂吗,一大堆现成的不用?
cyclists 大佬有话说 :
h2o 大佬有话说 : 2020-3-7 20:55
不就是个定期申请证书吗,用搞的这么复杂吗,一大堆现成的不用?
MJJ在于折腾,乐趣
千牛 大佬有话说 :
https://s2.ax1x.com/2020/03/07/3jDaL9.png
我觉得你多echo几句应该可以搞定的。。。。我只是格式化了一下代码
cyclists 大佬有话说 :
千牛 大佬有话说 : 2020-3-7 21:08
我觉得你多echo几句应该可以搞定的。。。。我只是格式化了一下代码
大佬牛皮,有啥解决方案吗?