主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情! |
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作 |
感谢之前帖子里的12楼大佬帮我写了个脚本,由于他工作原因,不太方便经常打扰别人。
# !/bin/bash -x 我执行 bash running.sh 1 的时候,rundate.log里会自动写入日期,但是root根目录并没有创建 xxx 文件,把上述里的bash mkdir xxx代码替换成 bash acme.sh —renew-all ,我去acme.sh.log日志里看也没有最新执行时间。 |
网友回复网友:
注册网友: 不好意思,我在家里没有使用电脑上网,孩子在上课用。所以没及时回复你的信息。 1、bash mkdir xxx 这一行你的使用有错误,bash是脚本执行命令,mkdir是创建目录或文件命令,你把bash去掉就生效了。 2、sed -i “4s/[0-9] [0-9] * /$curr_run_time/” mkdir xxx 这一行里因为你一次运行了两个命令,所以也不会生效,正确的用法是 sed -i “4s/[0-9] [0-9] * /$curr_run_time/” mkdir xxx 或者你分段来运行 sed -i “4s/[0-9] [0-9] * /$curr_run_time/” mkdir xxx
cyclists网友: 不就是个定期申请证书吗,用搞的这么复杂吗,一大堆现成的不用?
Ruclinux网友: MJJ在于折腾,乐趣
h2o网友: 我觉得你多echo几句应该可以搞定的。。。。我只是格式化了一下代码
千牛网友: 付费请人得解
cyclists网友: 知识盲区!
xcy1020网友: 这个脚本的正式调试方法是 通过修改rundate.log文件里的|左右的信息来调试 当当前的时间(年月日)=rundate.log文本里的年月日,脚本是不会生效的,你把rundate.log里的|右边的日期改一个数,只要不与现行时间的日数相同,脚本就会生效了。
Thanks to the 12 floor guy in the previous post for writing a script for me. Because of his work, it's not convenient to disturb others often. # !/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/[0-9] [0-9] * /$curr_run_time/” mkdir xxx
echo -e “1|${ni}” > “${phat}”
fi
Fi
fi
fi when I execute bash running.sh 1, the date will be automatically written in the rundate.log, but the root directory does not create the XXX file. Replace the bash MKDIR XXX code in the above with bash acme.sh-renew-all. I go to acme.sh.log to see the latest execution time. Can you help me to have a look? Sorry, I didn't use the computer to surf the Internet at home, and the child was using it in class. So I didn't reply to your message in time. 1. Bash MKDIR XXX is wrong in your use. Bash is a script command, and MKDIR is a command to create a directory or file. If you remove bash, it will take effect. 2. Sed - I “4s / [0-9] [0-9] * / $curr_run_time / ” MKDIR XXX will not take effect because you run two commands at a time. The correct usage is sed - I “4s / [0-9] [0-9] * / $curr_run_time / ” & ; MKDIR XXX or you can run sed - I “4s / [0-9] [0-9] * / $curr_run_time / ” MKDIR XXX cyclists in sections: isn't it just a regular certificate application? Is it so complicated? A lot of ready-made ones are not used? Ruclinux: mjj is about tossing. I think you can do it with a few more words of echo.... I just formatted the code cyclists: what's the solution? Qianniu: the payer has to understand cyclists: knowledge blind area! Xcy1020: the official debugging method of this script is to debug by modifying the information in the rundate.log file. When the current time (MM DD YY) = MM DD YY in the rundate.log text, the script will not take effect. You change the date on the right side of rundate.log to a number. As long as it is not the same as the current time, the script will take effect.
这几篇文章你可能也喜欢:
- 搬瓦工VPS,限量款套餐补货,美国CN2 GIA/日本软银/荷兰AS9929,1Gbps超大高端网络线路,KVM虚拟架构,1核1G内存1Gbps带宽,80美元/年,机房可随意切换
- CloudCone,美国Win系统VPS云服务器少量补货,美国洛杉矶MC机房,KVM虚拟架构,3核4G内存1Gbps带宽,17.49美元/月
- LOCVPS,双12特惠,香港免备案VPS云服务器终身65折,香港葵湾机房,CN2+BGP/CN2网络,KVM虚拟架构,1核2G内存2Mbps带宽不限流量,29.25元/月
- 恒创科技,全场3折优惠起,免备案香港VPS云服务器低至28元/月,香港/美国,新增多款特价服务器,1核1G内存5Mbps带宽不限流量,292元/年
- 萤光云,香港VPS云服务器测评报告,回国优化线路,香港VPS测评,萤光云VPS好不好?萤光云香港VPS云服务器值得购买吗?
本文由主机参考刊发,转载请注明:再次求助,SH 脚本大佬进来看看我这个是啥问题! - Ask for help again, SH script big guy comes in to see what problem this is! https://zhujicankao.com/5415.html
评论前必须登录!
注册