VPS参考测评推荐
专注分享VPS主机优惠信息
衡天云优惠活动
华纳云优惠活动
荫云优惠活动

再次求助,SH 脚本大佬进来看看我这个是啥问题! - Ask for help again, SH script big guy comes in to see what problem this is!

主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作

感谢之前帖子里的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/[0-9] [0-9] * /$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日志里看也没有最新执行时间。

各位热心大佬可以帮忙看看吗?

网友回复网友:

注册网友: 不好意思,我在家里没有使用电脑上网,孩子在上课用。所以没及时回复你的信息。 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网友: 大佬牛皮,有啥解决方案吗?

千牛网友: 付费请人得解

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.

这几篇文章你可能也喜欢:

本文由主机参考刊发,转载请注明:再次求助,SH 脚本大佬进来看看我这个是啥问题! - Ask for help again, SH script big guy comes in to see what problem this is! https://zhujicankao.com/5415.html

【腾讯云】领8888元采购礼包,抢爆款云服务器 每月 9元起,个人开发者加享折上折!
打赏
转载请注明原文链接:主机参考 » 再次求助,SH 脚本大佬进来看看我这个是啥问题! - Ask for help again, SH script big guy comes in to see what problem this is!
主机参考仅做资料收集,不对商家任何信息及交易做信用担保,购买前请注意风险,有交易纠纷请自行解决!请查阅:特别声明

评论 抢沙发

评论前必须登录!