rc.local 注意事項,call python script, file position

如果要在 rc.local 呼叫 python script
python script 的位置需使用絕對路徑
其 python script 裡的有關 file 的位置也需使用 絕對路徑

如果要在 rc.local 呼叫建立 file
file 的位置需使用絕對路徑

rc.local 位在 /etc 下
rc.local

touch test          #---  沒有生效
touch ./test        #---  沒有生效
touch /etc/test   #---  生效

.....
.....
python test.py         #---  沒有生效
python ./test.py       #---  沒有生效
python /etc/test.py  #---  生效
.....
.....

test.py 位在 /etc/ 下
test.py

import subprocess

subprocess.call("touch test4", shell=True)          #---  沒有生效
subprocess.call("touch ./test5", shell=True)        #---  沒有生效
subprocess.call("touch /etc/test6", shell=True)   #---  生效
原文地址:https://www.cnblogs.com/youchihwang/p/11202298.html