{"id":492,"date":"2019-05-29T12:04:35","date_gmt":"2019-05-29T04:04:35","guid":{"rendered":"http:\/\/blog.lovexu.cc\/?p=492"},"modified":"2019-05-29T12:04:35","modified_gmt":"2019-05-29T04:04:35","slug":"ubuntu-18-04-%e8%ae%be%e7%bd%ae%e5%bc%80%e6%9c%ba%e5%90%af%e5%8a%a8%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/lox.im\/index.php\/492.html","title":{"rendered":"ubuntu-18.04 \u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\u811a\u672c"},"content":{"rendered":"\n<p>\u53c2\u9605\u4e0b\u5217\u94fe\u63a5<\/p>\n\n\n\n<p><a href=\"https:\/\/askubuntu.com\/questions\/886620\/how-can-i-execute-command-on-startup-rc-local-alternative-on-ubuntu-16-10\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/askubuntu.com\/questions\/886620\/how-can-i-execute-command-on-startup-rc-local-alternative-on-ubuntu-16-10<\/a><\/p>\n\n\n\n<p>ubuntu-18.04\u4e0d\u80fd\u50cfubuntu14\u4e00\u6837\u901a\u8fc7\u7f16\u8f91rc.local\u6765\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\u811a\u672c\uff0c\u901a\u8fc7\u4e0b\u5217\u7b80\u5355\u8bbe\u7f6e\u540e\uff0c\u53ef\u4ee5\u4f7frc.local\u91cd\u65b0\u53d1\u6325\u4f5c\u7528\u3002<\/p>\n\n\n\n<p>1\u3001\u5efa\u7acbrc-local.service\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/systemd\/system\/rc-local.service<\/code><\/pre>\n\n\n\n<p>2\u3001\u5c06\u4e0b\u5217\u5185\u5bb9\u590d\u5236\u8fdbrc-local.service\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[Unit]\nDescription=\/etc\/rc.local Compatibility\nConditionPathExists=\/etc\/rc.local\n \n[Service]\nType=forking\nExecStart=\/etc\/rc.local start\nTimeoutSec=0\nStandardOutput=tty\nRemainAfterExit=yes\nSysVStartPriority=99\n \n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n\n\n\n<p>3\u3001\u521b\u5efa\u6587\u4ef6rc.local\u3000\u3000<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/rc.local<\/code><\/pre>\n\n\n\n<p>4\u3001\u5c06\u4e0b\u5217\u5185\u5bb9\u590d\u5236\u8fdbrc.local\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/sh -e\n#\n# rc.local\n#\n# This script is executed at the end of each multiuser runlevel.\n# Make sure that the script will \"exit 0\" on success or any other\n# value on error.\n#\n# In order to enable or disable this script just change the execution\n# bits.\n#\n# By default this script does nothing.\necho \"\u770b\u5230\u8fd9\u884c\u5b57\uff0c\u8bf4\u660e\u6dfb\u52a0\u81ea\u542f\u52a8\u811a\u672c\u6210\u529f\u3002\" > \/usr\/local\/test.log\nexit 0<\/code><\/pre>\n\n\n\n<p>5\u3001\u7ed9rc.local\u52a0\u4e0a\u6743\u9650<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chmod +x \/etc\/rc.local<\/code><\/pre>\n\n\n\n<p>6\u3001\u542f\u7528\u670d\u52a1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable rc-local<\/code><\/pre>\n\n\n\n<p>7\u3001\u542f\u52a8\u670d\u52a1\u5e76\u68c0\u67e5\u72b6\u6001<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start rc-local.service\nsudo systemctl status rc-local.service<\/code><\/pre>\n\n\n\n<p>8\u3001\u91cd\u542f\u5e76\u68c0\u67e5test.log\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/usr\/local\/test.log\u3000\u3000<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u80fd\u770b\u5230\u5185\u5bb9\uff0c\u8bf4\u660e\u8bbe\u7f6e\u6210\u529f\uff0c\u4f60\u5c31\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91rc.local\u6587\u4ef6\u6765\u8bbe\u7f6e\u542f\u52a8\u811a\u672c\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u9605\u4e0b\u5217\u94fe\u63a5 https:\/\/askubuntu.com\/questions\/886620\/how-can-i-execute-c &#8230;<\/p>\n","protected":false},"author":1,"featured_media":379,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[4],"tags":[24],"class_list":["post-492","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-internet","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/posts\/492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/comments?post=492"}],"version-history":[{"count":0,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/posts\/492\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/media\/379"}],"wp:attachment":[{"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/media?parent=492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/categories?post=492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/tags?post=492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}