{"id":90146,"date":"2024-03-02T09:39:13","date_gmt":"2024-03-02T01:39:13","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=90146"},"modified":"2024-03-02T09:39:13","modified_gmt":"2024-03-02T01:39:13","slug":"linux-start-reboot-script","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-start-reboot-script.html","title":{"rendered":"\u6559\u4f60\u5982\u4f55\u7f16\u5199Linux\u542f\u52a8\u6216\u91cd\u542f\u65f6\u7684\u6267\u884c\u547d\u4ee4\/\u811a\u672c"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6709\u65f6\u53ef\u80fd\u4f1a\u9700\u8981\u5728\u91cd\u542f\u65f6\u6216\u8005\u6bcf\u6b21\u7cfb\u7edf\u542f\u52a8\u65f6\u8fd0\u884c\u67d0\u4e9b\u547d\u4ee4\u6216\u8005\u811a\u672c\u3002\u6211\u4eec\u8981\u600e\u6837\u505a\u5462\uff1f\u672c\u6587\u4e2d\u6211\u4eec\u5c31\u5bf9\u6b64\u8fdb\u884c\u8ba8\u8bba\u3002 \u6211\u4eec\u4f1a\u7528\u4e24\u79cd\u65b9\u6cd5\u6765\u63cf\u8ff0\u5982\u4f55\u5728 CentOS\/RHEL \u4ee5\u53ca Ubuntu \u7cfb\u7edf\u4e0a\u505a\u5230\u91cd\u542f\u6216\u8005\u7cfb\u7edf\u542f\u52a8\u65f6\u6267\u884c\u547d\u4ee4\u548c\u811a\u672c\u3002 \u4e24\u79cd\u65b9\u6cd5\u90fd\u901a\u8fc7\u4e86\u6d4b\u8bd5\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u6709\u65f6\u53ef\u80fd\u4f1a\u9700\u8981\u5728\u91cd\u542f\u65f6\u6216\u8005\u6bcf\u6b21\u7cfb\u7edf\u542f\u52a8\u65f6\u8fd0\u884c\u67d0\u4e9b\u547d\u4ee4\u6216\u8005\u811a\u672c\u3002\u6211\u4eec\u8981\u600e\u6837\u505a\u5462\uff1f\u672c\u6587\u4e2d\u6211\u4eec\u5c31\u5bf9\u6b64\u8fdb\u884c\u8ba8\u8bba\u3002 \u6211\u4eec\u4f1a\u7528\u4e24\u79cd\u65b9\u6cd5\u6765\u63cf\u8ff0\u5982\u4f55\u5728 CentOS\/RHEL \u4ee5\u53ca Ubuntu \u7cfb\u7edf\u4e0a\u505a\u5230\u91cd\u542f\u6216\u8005\u7cfb\u7edf\u542f\u52a8\u65f6\u6267\u884c\u547d\u4ee4\u548c\u811a\u672c\u3002 \u4e24\u79cd\u65b9\u6cd5\u90fd\u901a\u8fc7\u4e86\u6d4b\u8bd5\u3002<\/p>\n

\u65b9\u6cd5 1 \u2013 \u4f7f\u7528 rc.local<\/strong><\/div>\n

\u8fd9\u79cd\u65b9\u6cd5\u4f1a\u5229\u7528 \/etc\/ \u4e2d\u7684 rc.local \u6587\u4ef6\u6765\u5728\u542f\u52a8\u65f6\u6267\u884c\u811a\u672c\u4e0e\u547d\u4ee4\u3002\u6211\u4eec\u5728\u6587\u4ef6\u4e2d\u52a0\u4e0a\u4e00\u884c\u6765\u6267\u884c\u811a\u672c\uff0c\u8fd9\u6837\u6bcf\u6b21\u542f\u52a8\u7cfb\u7edf\u65f6\uff0c\u90fd\u4f1a\u6267\u884c\u8be5\u811a\u672c\u3002<\/p>\n

\u4e0d\u8fc7\u6211\u4eec\u9996\u5148\u9700\u8981\u4e3a \/etc\/rc.local \u6dfb\u52a0\u6267\u884c\u6743\u9650\uff0c
\n$ sudo chmod +x \/etc\/rc.local<\/span><\/p>\n

\u7136\u540e\u5c06\u8981\u6267\u884c\u7684\u811a\u672c\u52a0\u5165\u5176\u4e2d\uff1a
\n$ sudo vi \/etc\/rc.local<\/span><\/p>\n

\u5728\u6587\u4ef6\u6700\u540e\u52a0\u4e0a\uff1a
\nsh \/root\/script.sh &<\/span><\/p>\n

\u7136\u540e\u4fdd\u5b58\u6587\u4ef6\u5e76\u9000\u51fa\u3002\u4f7f\u7528 rc.local \u6587\u4ef6\u6765\u6267\u884c\u547d\u4ee4\u4e5f\u662f\u4e00\u6837\u7684\uff0c\u4f46\u662f\u4e00\u5b9a\u8981\u8bb0\u5f97\u586b\u5199\u547d\u4ee4\u7684\u5b8c\u6574\u8def\u5f84\u3002 \u60f3\u77e5\u9053\u547d\u4ee4\u7684\u5b8c\u6574\u8def\u5f84\u53ef\u4ee5\u8fd0\u884c\uff1a
\n$ which command<\/span><\/p>\n

\u6bd4\u5982\uff1a
\n$ which shutter
\n\/usr\/bin\/shutter
\n<\/span><\/p>\n

\u5982\u679c\u662f CentOS\uff0c\u6211\u4eec\u4fee\u6539\u7684\u662f\u6587\u4ef6 \/etc\/rc.d\/rc.local \u800c\u4e0d\u662f \/etc\/rc.local\u3002 \u4e0d\u8fc7\u6211\u4eec\u4e5f\u9700\u8981\u5148\u4e3a\u8be5\u6587\u4ef6\u6dfb\u52a0\u53ef\u6267\u884c\u6743\u9650\u3002
\n\u6ce8\u610f:- \u542f\u52a8\u65f6\u6267\u884c\u7684\u811a\u672c\uff0c\u8bf7\u4e00\u5b9a\u4fdd\u8bc1\u662f\u4ee5 exit 0 \u7ed3\u5c3e\u7684\u3002<\/p>\n

\u65b9\u6cd5 2 \u2013 \u4f7f\u7528 Crontab<\/strong><\/div>\n

\u8be5\u65b9\u6cd5\u6700\u7b80\u5355\u4e86\u3002\u6211\u4eec\u521b\u5efa\u4e00\u4e2a cron \u4efb\u52a1\uff0c\u8fd9\u4e2a\u4efb\u52a1\u5728\u7cfb\u7edf\u542f\u52a8\u540e\u7b49\u5f85 90 \u79d2\uff0c\u7136\u540e\u6267\u884c\u547d\u4ee4\u548c\u811a\u672c\u3002<\/p>\n

\u8981\u521b\u5efa cron \u4efb\u52a1\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u6267\u884c
\n$ crontab -e<\/span><\/p>\n

\u7136\u540e\u8f93\u5165\u4e0b\u884c\u5185\u5bb9\uff0c
\n@reboot ( sleep 90 ; sh \\location\\script.sh )<\/span><\/p>\n

\u8fd9\u91cc \\location\\script.sh \u5c31\u662f\u5f85\u6267\u884c\u811a\u672c\u7684\u5730\u5740\u3002<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/os.51cto.com\/art\/201712\/560530.htm<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/linux-start-reboot-script.html<\/a>\u7f16\u8f91\uff1a\u5468\u6653\u96ea\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb \u6709\u65f6\u53ef\u80fd\u4f1a\u9700\u8981\u5728\u91cd\u542f\u65f6\u6216\u8005\u6bcf\u6b21\u7cfb\u7edf\u542f\u52a8\u65f6\u8fd0\u884c\u67d0\u4e9b\u547d\u4ee4\u6216\u8005\u811a\u672c\u3002\u6211\u4eec\u8981\u600e\u6837\u505a\u5462\uff1f\u672c\u6587\u4e2d\u6211\u4eec\u5c31\u5bf9\u6b64\u8fdb\u884c\u8ba8\u8bba\u3002 […]<\/p>\n","protected":false},"author":63,"featured_media":90151,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-90146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/90146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=90146"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/90146\/revisions"}],"predecessor-version":[{"id":90191,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/90146\/revisions\/90191"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/90151"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=90146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=90146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=90146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}