{"id":560526,"date":"2022-12-01T22:19:11","date_gmt":"2022-12-01T14:19:11","guid":{"rendered":"http:\/\/4563.org\/?p=560526"},"modified":"2022-12-01T22:19:11","modified_gmt":"2022-12-01T14:19:11","slug":"sh%e8%84%9a%e6%9c%ac%e7%9b%b4%e6%8e%a5%e6%89%a7%e8%a1%8c%e8%bf%94%e5%9b%9e%e7%bb%93%e6%9e%9c%e6%ad%a3%e5%b8%b8%ef%bc%8c%e4%b8%80%e4%bd%bf%e7%94%a8crontab%e5%b0%b1%e4%b8%8d%e6%ad%a3%e5%b8%b8","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=560526","title":{"rendered":"sh\u811a\u672c\u76f4\u63a5\u6267\u884c\u8fd4\u56de\u7ed3\u679c\u6b63\u5e38\uff0c\u4e00\u4f7f\u7528crontab\u5c31\u4e0d\u6b63\u5e38"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>skywing<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3>sh\u811a\u672c\u76f4\u63a5\u6267\u884c\u8fd4\u56de\u7ed3\u679c\u6b63\u5e38\uff0c\u4e00\u4f7f\u7528crontab\u5c31\u4e0d\u6b63\u5e38<\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 skywing \u4e8e 2022-12-1 21:44 \u7f16\u8f91 <\/p>\n<p> #!\/usr\/bin\/env bash<br \/>  get_ip() {<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;new_ip=`dig domain.com +noall +answer | awk &#8216;{print $5}&#8217;`<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;old_ip=`iptables -L | grep dpt:443 | grep ACCEPT | awk &#8216;{print $4}&#8217;`<br \/>  }<\/p>\n<p>  check_ip () {<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;get_ip<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;echo &quot;the new ip is $new_ip&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;echo &quot;the old ip is $old_ip&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;if [[ &quot;${new_ip}&quot; != &quot;${old_ip}&quot; ]]; then<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;iptables -I INPUT -s $new_ip -p tcp &#8211;dport 443 -j ACCEPT<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;iptables -D INPUT -s $old_ip -p tcp &#8211;dport 443 -j ACCEPT<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;echo &quot;ip changed, update the ip.&quot;<br \/>  else<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;echo &quot;ip not change.&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;fi<br \/>  }<br \/>  check_ip<\/p>\n<p>  \u76f4\u63a5\u6267\u884c\u8fd9\u4e2a\u811a\u672c\uff0c\u8f93\u51fa<br \/>  the new ip is xxx<br \/>  the old ip is xxx<br \/>  ip not change.<\/p>\n<p>  \u4e00\u653e\u5230crontal\u91cc\u5b9a\u65f6\u6267\u884c\uff0c\u8f93\u51fa<br \/>  the new ip is xxx<br \/>  the old ip is<br \/>  ip changed, update the ip.<br \/>  old_ip \u76f4\u63a5\u8fd4\u56de\u7a7a\u503cyc002t<br \/>  \u8fd9\u662f\u600e\u4e48\u56de\u4e8b\u5462\uff1f\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>HOH<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tipt\u5728sbin\u91cc\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>lifetyper<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u697c\u4e0a\u5e94\u8be5\u662f\u6b63\u89e3\uff0c\u8fd9\u79cd\u811a\u672c\u6211\u90fd\u7528\u7edd\u5bf9\u8def\u5f84\u3002\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>skywing<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tHOH \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2022-12-1 21:44<br \/>  ipt\u5728sbin\u91cc<\/p>\n<p> \u7b2c\u4e00\u884c\u5199\u6210 #\/usr\/sbin bash\u8fd9\u4e2a\u811a\u672c\u5c31\u65e0\u6cd5\u901a\u8fc7\u6587\u4ef6\u8def\u5f84\u76f4\u63a5\u6267\u884c\uff0c\u63d0\u793a\u5982\u4e0b\u9519\u8bef<br \/>  -bash: .\/ip.sh: \/usr\/sbin: bad interpreter: Permission denied<br \/>  \u5fc5\u987b\u524d\u9762\u4f7f\u7528 bash\u624d\u80fd\u6b63\u5e38\u6267\u884c<\/p>\n<p>  \u4e3a\u4ec0\u4e48\u4f1a\u62a5\u8fd9\u4e2a\u9519\u8bef\u5462\uff1f<\/p>\n<p>  \t\t\t\t\t<strong>tiga<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tskywing \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2022-12-1 21:54<br \/>  \u7b2c\u4e00\u884c\u5199\u6210 #\/usr\/sbin bash\u8fd9\u4e2a\u811a\u672c\u5c31\u65e0\u6cd5\u901a\u8fc7\u6587\u4ef6\u8def\u5f84\u76f4\u63a5\u6267\u884c\uff0c\u63d0\u793a\u5982\u4e0b\u9519\u8bef<br \/>  -bash: .\/ip.sh: \/usr\/sb &#8230;<\/p>\n<p> \u770b\u4e50\u4e86<\/p>\n<p>  \u4eba\u5bb6\u8bf4\u7684\u662f iptables \u5728 sbin\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>zxxx<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\/usr\/sbin\/iptables &#8230;\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>skywing \u5927\u4f6c\u6709\u8bdd\u8bf4 : s&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/560526"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=560526"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/560526\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=560526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=560526"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=560526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}