Linux中沒有rc.local文件的完美解決方法
比較新的Linux發(fā)行版已經(jīng)沒有rc.local文件了。因為已經(jīng)將其服務(wù)化了。
解決方法:
1、設(shè)置rc-local.service
sudo vim /etc/systemd/system/rc-local.service [Unit] Description=/etc/rc.local Compatibility ConditionPathExists=/etc/rc.local [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99 [Install] WantedBy=multi-user.target
2、激活rc-local.service
sudo systemctl enable rc-local.service
3、添加啟動服務(wù)
手工創(chuàng)建或者拷貝已有的/etc/rc.local
,并賦予執(zhí)行權(quán)限
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # 下面這條是要開機啟動的命令 /home/selfcs/anaconda3/bin/python /home/selfcs/t.py > /home/selfcs/auto.log exit 0 #給予腳本執(zhí)行權(quán)限 sudo chmod +x /etc/rc.local
總結(jié)
以上所述是小編給大家介紹的Linux中沒有rc.local文件的完美解決方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
相關(guān)文章
Apache加速模塊mod_pagespeed安裝使用詳細介紹
這篇文章主要介紹了Apache加速模塊mod_pagespeed安裝使用詳細介紹,需要的朋友可以參考下2014-03-03詳解Ubuntu14.04橋接網(wǎng)絡(luò)設(shè)置與SSH登陸
本篇文章主要介紹了詳解Ubuntu14.04橋接網(wǎng)絡(luò)設(shè)置與SSH登陸,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-01-01詳解輕巧AMH虛擬主機面板安裝使用和GCE云空間搭建網(wǎng)站實例
這篇文章主要介紹了輕巧AMH虛擬主機面板安裝使用和GCE云空間搭建網(wǎng)站實例,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-07-07詳解CentOS升級Python2.6到Python2.7并安裝pip
本篇文章主要介紹了CentOS升級Python2.6到Python2.7并安裝pip,具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-03-03關(guān)于如何在崩潰或重啟后保持Linux進程運行的解決方法
在計算機系統(tǒng)中,進程的穩(wěn)定性和持久性對于確保系統(tǒng)正常運行至關(guān)重要,在 Linux 系統(tǒng)中,由于各種原因,進程可能會面臨崩潰或系統(tǒng)重啟的情況,為了確保關(guān)鍵進程的持續(xù)運行,我們需要采取一些措施來處理這種情況,文中給大家介紹的非常詳細,需要的朋友可以參考下2024-01-01