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

重慶分公司,新征程啟航

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

linux添加開(kāi)機(jī)啟動(dòng)腳本的方法-創(chuàng)新互聯(lián)

linux添加開(kāi)機(jī)啟動(dòng)腳本的方法:

創(chuàng)新互聯(lián)公司專(zhuān)注于沅江企業(yè)網(wǎng)站建設(shè),自適應(yīng)網(wǎng)站建設(shè),商城網(wǎng)站建設(shè)。沅江網(wǎng)站建設(shè)公司,為沅江等地區(qū)提供建站服務(wù)。全流程按需網(wǎng)站策劃,專(zhuān)業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)公司專(zhuān)業(yè)和態(tài)度為您提供的服務(wù)

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

/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)

一、修改開(kāi)機(jī)啟動(dòng)文件:/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開(kāi)機(jī)啟動(dòng)
/etc/init.d/nginx start                     # nginx開(kāi)機(jī)啟動(dòng)
supervisord -c /etc/supervisor/supervisord.conf         # supervisord開(kāi)機(jī)啟動(dòng)
/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

二、自己寫(xiě)一個(gè)shell腳本

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

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

# 1.將(腳本)啟動(dòng)文件移動(dòng)到 /etc/init.d/或者/etc/rc.d/init.d/目錄下。(前者是后者的軟連接)
mv /www/wwwroot/test.sh /etc/rc.d/init.d
 
# 2.啟動(dòng)文件前面務(wù)必添加如下三行代碼,否側(cè)會(huì)提示chkconfig不支持。
#!/bin/sh             告訴系統(tǒng)使用的shell,所以的shell腳本都是這樣
#chkconfig: 35 20 80        分別代表運(yùn)行級(jí)別,啟動(dòng)優(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.添加腳本到開(kāi)機(jī)自動(dòng)啟動(dòng)項(xiàng)目中。添加到chkconfig,開(kāi)機(jī)自啟動(dòng)。
[root@localhost ~]# cd /etc/rc.d/init.d
[root@localhost ~]# chkconfig --add test.sh
[root@localhost ~]# chkconfig test.sh on
 
# 5.關(guān)閉開(kāi)機(jī)啟動(dòng)
[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ù),通過(guò)Systemctl管理

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

[Unit]:服務(wù)的說(shuō)明
Description:描述服務(wù)
After:描述服務(wù)類(lèi)別
 
[Service]服務(wù)運(yùn)行參數(shù)的設(shè)置
Type=forking      是后臺(tái)運(yùn)行的形式
ExecStart        為服務(wù)的具體運(yùn)行命令
ExecReload       為服務(wù)的重啟命令
ExecStop        為服務(wù)的停止命令
PrivateTmp=True     表示給服務(wù)分配獨(dú)立的臨時(shí)空間
注意:?jiǎn)?dòng)、重啟、停止命令全部要求使用絕對(duì)路徑
 
[Install]        服務(wù)安裝的相關(guān)設(shè)置,可設(shè)置為多用戶(hù)
WantedBy=multi-user.target

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

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

3.設(shè)置開(kāi)機(jī)自啟動(dòng)(任意目錄下執(zhí)行)。如果執(zhí)行啟動(dòng)命令報(bào)錯(cuò),則執(zhí)行:systemctl daemon-reload

設(shè)置開(kāi)機(jī)自啟動(dòng)
[root@localhost ~]# systemctl enable nginx.service   
[root@localhost ~]# systemctl enable supervisord
 
停止開(kāi)機(jī)自啟動(dòng)
[root@localhost ~]# systemctl disable nginx.service
[root@localhost ~]# systemctl disable supervisord
 
驗(yàn)證一下是否為開(kāi)機(jī)啟動(dòng)
[root@localhost ~]# systemctl is-enabled nginx
[root@localhost ~]# systemctl is-enabled supervisord

4.其他命令

啟動(dòng)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ù)當(dāng)前狀態(tài)
[root@localhost ~]# systemctl status nginx.service
 
查看所有已啟動(dòng)的服務(wù)
[root@localhost ~]# systemctl list-units --type=service

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

# supervisord.service進(jìn)程管理服務(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怎樣添加開(kāi)機(jī)啟動(dòng)腳本?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注創(chuàng)新互聯(lián)其它相關(guān)文章!


網(wǎng)站欄目:linux添加開(kāi)機(jī)啟動(dòng)腳本的方法-創(chuàng)新互聯(lián)
標(biāo)題鏈接:http://www.xueling.net.cn/article/dhshdi.html

其他資訊

在線咨詢(xún)
服務(wù)熱線
服務(wù)熱線:028-86922220
TOP
主站蜘蛛池模板: 国产精品久久久久一区二区 | 激情久久久久 | 又爽又色禁片1000视频免费看 | 葵司在线视频 | 色婷婷综合久久久久中文字幕 | 蜜臀av性久久久久蜜臀av | 久久视频这里只精品3国产 亚洲欧美日本在线观看 | 麻豆国产在线播放 | 亚洲视屏在线观看 | 一个人看的ww在线视频 | 国产一区二区三区视频在线播放 | av激情小说| 日本一道本线一区免费 | 黄色片视频在线观看 | 免费观看亚洲视频 | 日本欧美一区二区三区在线观看 | 色蜜桃网| 亚洲在av极品无码天堂手机版 | 狂野欧美性猛交免费视频 | 日本精品网 | av中文字幕免费 | 国产69精品久久久久久久 | 91精品视频免费观看 | 精品免费久久久久久久苍 | 4438xx亚洲最大五色丁香 | 欧洲a视频 | 欧美一级二级视频 | 国产免费一区二区三区在线能观看 | 久久人人爽人人爽人人爽av | 亚洲av人无码激艳猛片 | 成人欧美一区二区三区色青冈 | 国产亚洲精品久久久久久无挡照片 | 成全视频大全免费观看 | 亚洲大片免费观看 | 少妇性按摩无码中文a片 | 男人午夜 | 国产aⅴ精品一区二区三区久久 | www.xxxx国产 | 91视频免费在线观看 | 亚洲欧美国产网曝综合网 | 明星ai换脸二三区入口 |