老熟女激烈的高潮_日韩一级黄色录像_亚洲1区2区3区视频_精品少妇一区二区三区在线播放_国产欧美日产久久_午夜福利精品导航凹凸

重慶分公司,新征程啟航

為企業(yè)提供網(wǎng)站建設(shè)、域名注冊、服務(wù)器等服務(wù)

Linux如何添加開機啟動腳本

這篇文章將為大家詳細講解有關(guān)Linux如何添加開機啟動腳本,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

成都創(chuàng)新互聯(lián)專注于織金網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供織金營銷型網(wǎng)站建設(shè),織金網(wǎng)站制作、織金網(wǎng)頁設(shè)計、織金網(wǎng)站官網(wǎng)定制、小程序開發(fā)服務(wù),打造織金網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供織金網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。

系統(tǒng)啟動時需要加載的配置文件

/etc/profile、/root/.bash_profile
/etc/bashrc、/root/.bashrc
/etc/profile.d/*.sh、/etc/profile.d/lang.sh
/etc/sysconfig/i18n、/etc/rc.local(/etc/rc.d/rc.local)

一、修改開機啟動文件:/etc/rc.local(或者/etc/rc.d/rc.local)

# 1.編輯rc.local文件
[root@localhost ~]# vi /etc/rc.local

# 2.修改rc.local文件,在 exit 0 前面加入以下命令。保存并退出。
/etc/init.d/MySQLd start                     # mysql開機啟動
/etc/init.d/nginx start                     # nginx開機啟動
supervisord -c /etc/supervisor/supervisord.conf         # supervisord開機啟動
/bin/bash /server/scripts/test.sh >/dev/null 2>/dev/null

# 3.最后修改rc.local文件的執(zhí)行權(quán)限
[root@localhost ~]# chmod +x /etc/rc.local
[root@localhost ~]# chmod 755 /etc/rc.local

二、自己寫一個shell腳本

將寫好的腳本(.sh文件)放到目錄 /etc/profile.d/ 下,系統(tǒng)啟動后就會自動執(zhí)行該目錄下的所有shell腳本。

三、通過chkconfig命令設(shè)置

# 1.將(腳本)啟動文件移動到 /etc/init.d/或者/etc/rc.d/init.d/目錄下。(前者是后者的軟連接)
mv /www/wwwroot/test.sh /etc/rc.d/init.d

# 2.啟動文件前面務(wù)必添加如下三行代碼,否側(cè)會提示chkconfig不支持。
#!/bin/sh             告訴系統(tǒng)使用的shell,所以的shell腳本都是這樣
#chkconfig: 35 20 80        分別代表運行級別,啟動優(yōu)先權(quán),關(guān)閉優(yōu)先權(quán),此行代碼必須
#description: http server     自己隨便發(fā)揮!!!,此行代碼必須
/bin/echo $(/bin/date +%F_%T) >> /tmp/test.log

# 3.增加腳本的可執(zhí)行權(quán)限
chmod +x /etc/rc.d/init.d/test.sh

# 4.添加腳本到開機自動啟動項目中。添加到chkconfig,開機自啟動。
[root@localhost ~]# cd /etc/rc.d/init.d
[root@localhost ~]# chkconfig --add test.sh
[root@localhost ~]# chkconfig test.sh on

# 5.關(guān)閉開機啟動 
[root@localhost ~]# chkconfig test.sh off

# 6.從chkconfig管理中刪除test.sh
[root@localhost ~]# chkconfig --del test.sh

# 7.查看chkconfig管理
[root@localhost ~]# chkconfig --list test.sh

四、自定義服務(wù)文件,添加到系統(tǒng)服務(wù),通過Systemctl管理

1.寫服務(wù)文件:如nginx.service、redis.service、supervisord.service

[Unit]:服務(wù)的說明
Description:描述服務(wù)
After:描述服務(wù)類別

[Service]服務(wù)運行參數(shù)的設(shè)置
Type=forking      是后臺運行的形式
ExecStart        為服務(wù)的具體運行命令
ExecReload       為服務(wù)的重啟命令
ExecStop        為服務(wù)的停止命令
PrivateTmp=True     表示給服務(wù)分配獨立的臨時空間
注意:啟動、重啟、停止命令全部要求使用絕對路徑

[Install]        服務(wù)安裝的相關(guān)設(shè)置,可設(shè)置為多用戶
WantedBy=multi-user.target

2.文件保存在目錄下:以754的權(quán)限。目錄路徑:/usr/lib/systemd/system。如上面的supervisord.service文件放在這個目錄下面。

[root@localhost ~]# cat /usr/lib/systemd/system/nginx.service
[root@localhost ~]# cat /usr/lib/systemd/system/supervisord.service

3.設(shè)置開機自啟動(任意目錄下執(zhí)行)。如果執(zhí)行啟動命令報錯,則執(zhí)行:systemctl daemon-reload

設(shè)置開機自啟動
[root@localhost ~]# systemctl enable nginx.service    
[root@localhost ~]# systemctl enable supervisord

停止開機自啟動
[root@localhost ~]# systemctl disable nginx.service
[root@localhost ~]# systemctl disable supervisord

驗證一下是否為開機啟動
[root@localhost ~]# systemctl is-enabled nginx
[root@localhost ~]# systemctl is-enabled supervisord

4.其他命令

啟動nginx服務(wù)
[root@localhost ~]# systemctl start nginx.service

停止nginx服務(wù)
[root@localhost ~]# systemctl start nginx.service

重啟nginx服務(wù)
[root@localhost ~]# systemctl restart nginx.service

查看nginx服務(wù)當前狀態(tài)
[root@localhost ~]# systemctl status nginx.service

查看所有已啟動的服務(wù)
[root@localhost ~]# systemctl list-units --type=service

5.服務(wù)文件示例:

# supervisord.service進程管理服務(wù)文件
[Unit]
Description=Process Monitoring and Control Daemon  # 內(nèi)容自己定義:Description=Supervisor daemon
After=rc-local.service nss-user-lookup.target

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop= /usr/bin/supervisorctl shutdown 
ExecReload=/usr/bin/supervisorctl reload
Restart=on-failure
RestartSec=42s
KillMode=process 

[Install]
WantedBy=multi-user.target
# nginx.service服務(wù)文件
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop

[Install]
WantedBy=multi-user.target
# redis.service服務(wù)文件
[Unit]
Description=Redis
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /etc/redis.conf
ExecStop=kill -INT `cat /tmp/redis.pid`
User=www
Group=www

[Install]
WantedBy=multi-user.target

什么是Linux系統(tǒng)

Linux是一種免費使用和自由傳播的類UNIX操作系統(tǒng),是一個基于POSIX的多用戶、多任務(wù)、支持多線程和多CPU的操作系統(tǒng),使用Linux能運行主要的Unix工具軟件、應(yīng)用程序和網(wǎng)絡(luò)協(xié)議。

關(guān)于“Linux如何添加開機啟動腳本”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。


分享題目:Linux如何添加開機啟動腳本
文章出自:http://www.xueling.net.cn/article/jhdooj.html

其他資訊

在線咨詢
服務(wù)熱線
服務(wù)熱線:028-86922220
TOP
主站蜘蛛池模板: 天堂av色| yw.尤物在线精品视频 | 精品亚洲国产视频 | 大地资源中文二页在线观看 | 久久产精品一区二区三区污欧美 | 国产欧美一区二区三区精品酒店 | 国产成人欧美一区二区三区一色天 | 午夜香蕉视频 | 日日夜夜网站 | 日本大尺码专区mv | 国产女精品 | 亚洲精品无码国产一区二区 | 欧美黑人巨大久久久精品一区小蓝 | 国产伦精品一区二区三区视频1 | 色偷一区国产精品 | 国产精品二区一区 | 99国内精品久久久久 | 天堂久久网 | 中文字幕12页 | 亚洲中文字幕永久在线不卡 | 在线亚州 | 国产娇小性色xxxxx视频 | 日韩精品免费在线观看 | A级毛片100部免费观看 | 无码粉嫩虎白一线天在线观看 | 啪啪免费视频网站 | 久久久久黑人强伦姧人妻 | 国产一级爽快片在线观看 | 成在人线av无码免费高潮水 | 蜜桃一级片 | 久久综合精品国产一区二区三区 | 麻豆视频免费看了 | 国产色综合一区二区三区 | 成视频年人黄网站视频福利 | 日本天堂免费观看 | 69久久夜色精品国产69 | 亚洲国产精品999久久久婷婷 | 99久久免费国产精精品 | 久久艹天天艹 | 综合热久久 | 无码视频免费一区二区 |