我有一個通過rc.local啓動的python守護進程。這個具有相同權限的腳本安裝在我有的其他幾個Ubuntu盒子上。它在這些安裝上運行沒有問題。也就是說,重新啓動該框後,守護進程正在運行。我的rc.local文件(Ubuntu)有什麼問題?
雖然這個特殊的安裝,守護進程沒有運行到登錄時,並檢查進程的存在。系統之間的的rc.local文件是相同的(或至少足夠接近):
[email protected]:~$ cat /etc/rc.local
#!/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.
python /var/www/myDaemon/Main.py > /var/log/somelog.txt
exit 0
的權限包括:
[email protected]:~$ ls -la /etc/rc.local
-rwxr-xr-x 1 localaccount localaccount 370 Jun 3 11:04 rc.local
我測試如果rc.local中處理得到通過使用該測試執行rc.local:
[email protected]:/var/log/sosmsd$ cat /etc/rc.local
#!/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.
echo "test" > /home/localaccount/test1
/usr/bin/python /var/www/sosms/sosmsd/Main.py > /var/log/sosmsd/log/log
echo "test" > /home/localaccount/test2
exit 0
[email protected]:/var/log/sosmsd$
並且只有第一個測試文件(test1)在重新啓動盒子後創建。我猜這意味着蟒蛇線造成某種問題的,但我得到在/ var沒有輸出/日誌/ sosmsd /日誌/日誌:
[email protected]:~$ ls
test1
更新:
我再其次larsks的意見和決定,我是從啓動python腳本收到此錯誤:
mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
這是否意味着MySQL已經不得不被初始化的機會之前,正在執行的rc.local中?我從哪裏出發?
您的建議幫助了我。 –