有個腳本需要開機啟動,結果 rc.local 老兄非常不給面子,折騰的心力交瘁死活就是不執行.
網上查了很多資料:
/etc/rc.d/rc.local
有執行權限
source /etc/profile
載入環境變量都沒有解決問題
但我考慮肯定還是環境變量有問題, ssh 登上來就能執行,咋 rc.local
就不行呢!!!
于是,絕頂聰明的本人想出了一個絕頂聰明的辦法... 通過 su -c
自動帶入環境變量...
OK, reboot 腳本終于開機啟動了 (?????)
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
su -c /home/app/search/start.pl #就是這一行(?????)
touch /var/lock/subsys/local