{"componentChunkName":"component---src-templates-blog-post-js","path":"/raspberry_pi/2020-07-17-Raspberry-pi-3-b+에서-Python-자동-실행/","result":{"data":{"site":{"siteMetadata":{"title":"Jinote","author":"jinoan","siteUrl":"https://jinoan.netlify.app","comment":{"disqusShortName":"","utterances":"jinoan/blog-comment"},"sponsor":{"buyMeACoffeeId":"jinoan"}}},"markdownRemark":{"id":"8ce0967c-be2d-5c4e-9e22-73f4c4a0eafb","excerpt":"실행하고자 하는 파이썬 파일명과 경로가  라고 가정 Shell script에 파이썬 파일 실행 코드 작성 (쉘 스크립트 파일명과 경로가  라고 가정) 홈()에 있는  파일에 아래 코드를 추가","html":"<p>실행하고자 하는 파이썬 파일명과 경로가 <code class=\"language-text\">/home/pi/Desktop/filename.py</code> 라고 가정</p>\n<ol>\n<li>\n<p>Shell script에 파이썬 파일 실행 코드 작성</p>\n<p>(쉘 스크립트 파일명과 경로가 <code class=\"language-text\">~/Desktop/run.sh</code> 라고 가정)</p>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">cd /home/pi/Desktop/  # 파이썬 파일이 있는 경로로 이동\nnohup python3 filename.py &amp;</code></pre></div>\n</li>\n<li>\n<p>홈(<code class=\"language-text\">/home/pi</code>)에 있는 <code class=\"language-text\">.profile</code> 파일에 아래 코드를 추가</p>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\"># insert this code in /home/pi/.profile\npid=$(ps aux | grep python3 | grep filename.py | awk &#39;{print $2}&#39;)\nif [ -z &quot;$pid&quot; ]; then\n   /bin/sh /home/pi/Desktop/run.sh\nfi</code></pre></div>\n</li>\n</ol>","frontmatter":{"title":"Raspberry Pi 3 B+에서 Python 자동 실행","date":"July 17, 2020"}}},"pageContext":{"slug":"/raspberry_pi/2020-07-17-Raspberry-pi-3-b+에서-Python-자동-실행/","previous":{"fields":{"slug":"/raspberry_pi/2020-07-17-Raspberry-pi-3-b+-고정IP-설정/"},"frontmatter":{"title":"Raspberry Pi 3 B+ 고정IP 설정","category":"raspberry_pi","draft":false}},"next":{"fields":{"slug":"/raspberry_pi/2020-07-24-Raspberry-Pi-3-B+-무선랜-비활성화/"},"frontmatter":{"title":"Raspberry Pi 3 B+ 무선 랜 비활성화","category":"raspberry_pi","draft":false}}}},"staticQueryHashes":["3128451518","521680639"]}