我想在使用systemd重新啓動時自動運行python文件。我嘗試使用systemd的原因是因爲我的python文件需要網絡連接並在該時間點可用,並且/ home/pi目錄需要準備好使用並且系統時間已由NTP更新繼續。 但是我收到以下錯誤,當我嘗試啓動腳本:重啓後使用systemd在raspbian上自動運行python文件
systemctl start mysript.service
無法啓動myscript.service:單位myscript.service未能 負載:無效的參數。有關詳細信息,請參閱系統日誌和'systemctl狀態 myscript.service'。
systemctl status myscript.service
myscript.service 加載:錯誤(原因:無效的參數) 有效無效(死)
myscript.service缺乏ExecStart設置。拒。
以下是myscript.service:
[unit]
Description=MyPythonFile
After=multi-user.target
[service]
Type=idle
ExecStart=/usr/bin/python3 /home/pi/mypythonfile/file.py
[Install]
WantedBy=multi-user.target
做任何人有任何想法,爲什麼我收到這個錯誤?
[編輯] 引用這篇文章:https://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-on-boot-using-systemd/
現在可以加載該服務,但是因爲我的Python程序是用Tkinter我收到一個錯誤。
_tkinter.TclError: couldn't connect to display "0.0"
myscript.service: main process exited, code=exited, status=1/FAILURE
Unit myscript.service entered failed state.
我該如何解決這個錯誤?
編輯我的帖子有新錯誤,請幫忙! –
編輯我的答案 – Ben10
如果這沒有幫助 - 看看這個:http://www.raspberry-projects。在「設置應用程序」下的com/pi/pi-operating-systems/raspbian/auto-running-programs-gui – Ben10