{"id":97404,"date":"2024-06-12T10:58:48","date_gmt":"2024-06-12T02:58:48","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=97404"},"modified":"2024-06-12T10:58:48","modified_gmt":"2024-06-12T02:58:48","slug":"linux-script","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-script.html","title":{"rendered":"\u4f20\u6388Linux\u914d\u7f6e\u5f00\u673a\u81ea\u542f\u52a8\u6267\u884c\u811a\u672c\u79d8\u7c4d"},"content":{"rendered":"
\r\n[root@c69-01 scripts]# vim \/server\/scripts\/qidong.sh\r\n\r\n[root@c69-01 scripts]# cat \/server\/scripts\/qidong.sh\r\n#!\/bin\/bash\r\n\/bin\/echo $(\/bin\/date +%F_%T) >> \/tmp\/qidong.log\r\n<\/pre>\n\u65b9\u6cd5\u4e00\uff1a\u4fee\u6539\/etc\/rc.local<\/strong><\/div>\n\/etc\/rc.local\uff0c\u8be5\u6587\u4ef6\u4e3a\u94fe\u63a5\u6587\u4ef6<\/p>\n
\r\n[root@c69-01 ~]# ll \/etc\/rc.local \r\nlrwxrwxrwx. 1 root root 13 Feb 5 10:03 \/etc\/rc.local -> rc.d\/rc.local\r\n<\/pre>\n\u4fee\u6539\/etc\/rc.local\u6587\u4ef6<\/p>\n
\r\n[root@c69-01 scripts]# tail -n 1 \/etc\/rc.local \r\n\/bin\/bash \/server\/scripts\/qidong.sh >\/dev\/null 2>\/dev\/null\r\n<\/pre>\n\u91cd\u542f\u7cfb\u7edf\uff0c\u67e5\u770b\u7ed3\u679c<\/p>\n
\r\n[root@c69-01 ~]# cat \/tmp\/qidong.log \r\n2018-02-19_23:30:56\r\n<\/pre>\n\u5df2\u5f00\u673a\u81ea\u542f\u52a8\u8be5\u811a\u672c<\/p>\n
\u65b9\u6cd5\u4e8c\uff1achkconfig\u7ba1\u7406<\/strong><\/div>\n\u5220\u9664\u6389\u65b9\u6cd5\u4e00\u7684\u914d\u7f6e<\/p>\n
\r\n[root@c69-01 ~]# vim \/etc\/init.d\/test \r\n#!\/bin\/bash\r\n# chkconfig: 3 88 88\r\n\/bin\/bash \/server\/scripts\/qidong.sh >\/dev\/null 2>\/dev\/null\r\n\r\n[root@c69-01 ~]# chmod +x \/etc\/init.d\/test\r\n<\/pre>\n\u6dfb\u52a0\u5230chkconfig\uff0c\u5f00\u673a\u81ea\u542f\u52a8 <\/p>\n
\r\n[root@c69-01 ~]# chkconfig --add test\r\n[root@c69-01 ~]# chkconfig --list test\r\ntest \t0:off\t1:off\t2:off\t3:on\t4:off\t5:off\t6:off\r\n<\/pre>\n\u91cd\u542f\u7cfb\u7edf\uff0c\u67e5\u770b\u7ed3\u679c<\/p>\n
\r\n[root@c69-01 ~]# cat \/tmp\/qidong.log \r\n2018-02-19_23:30:56\r\n2018-02-19_23:59:10\r\n<\/pre>\n\u64cd\u4f5c\u6210\u529f<\/p>\n
\u5173\u95ed\u5f00\u673a\u542f\u52a8 <\/p>\n
\r\n[root@c69-01 ~]# chkconfig test off\r\n[root@c69-01 ~]# chkconfig --list test\r\ntest \t0:off\t1:off\t2:off\t3:off\t4:off\t5:off\t6:off\r\n<\/pre>\n\u4ecechkconfig\u7ba1\u7406\u4e2d\u5220\u9664test<\/p>\n
\r\n[root@c69-01 ~]# chkconfig --list test\r\ntest \t0:off\t1:off\t2:off\t3:off\t4:off\t5:off\t6:off\r\n\r\n[root@c69-01 ~]# chkconfig --del test\r\n\r\n[root@c69-01 ~]# chkconfig --list test\r\nservice test supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add test')\r\n <\/pre>\n\u4ee5\u4e0a2\u79cd\u5f00\u673a\u81ea\u542f\u52a8\u811a\u672c\u7684\u65b9\u6cd5\uff0c\u4ec5\u4f9b\u53c2\u8003\uff0c\u8bfb\u8005\u53ef\u6839\u636e\u81ea\u5df1\u7684\u60c5\u51b5\uff0c\u8fdb\u884c\u914d\u7f6e\uff01<\/p>\n
\u6ce8\uff1a\u6211\u4f7f\u7528\u7684\u7cfb\u7edf\u4e3aCentOS release 6.9 (Final)<\/p>\n
\n\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/my.oschina.net\/u\/3285916\/blog\/1622358<\/a><\/p>\n