0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ラズパイ起動時にpythonファイルを実行(デバッグ方法つき)

Posted at

モチベ

  • Raspberry Pi起動時にPythonを実行したい
  • rc.localみたいな深いところは触りたくない

方法

  • 移動
    • cd /etc/systemd/system
  • serviceファイルを作る
    • sudo nano やりたいこと.service
    • 以下の通り書く
      [Unit]
      Description=実行する内容をメモ
      
      [Service]
      ExecStart=/user/bin/python3 /home/ユーザ名/Desktop/実行したいもの.py
      
      [Install]
      WantedBy=multi-user.target
      
  • 登録&試しに今実行させてみる
    • sudo systemctl daemon-reload
    • sudo systemctl start やりたいこと.service
  • ちゃんと実行できているか確認する
    • sudo systemctl status やりたいこと.service

所感

  • sudo systemctl startだけではエラーで途中停止していたとしても気付かない.statusでエラーメッセージを閲覧可能なので,ここを確認すること.
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?