比較新的Linux發(fā)行版已經(jīng)沒有rc.local文件了。因為已經(jīng)將其服務化了。
解決方法:
1、設置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、添加啟動服務
手工創(chuàng)建或者拷貝已有的/etc/rc.local
,并賦予執(zhí)行權限
#!/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í)行權限 sudo chmod +x /etc/rc.local
總結
以上所述是小編給大家介紹的Linux中沒有rc.local文件的完美解決方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!