0

I have the following code:

import os
import time

def temp_core():
    temp = os.popen("vcgencmd measure_temp").readline()
    return(temp.replace("temp=",""))

while(True):
    Temp = temp_core()
    if Temp > 70:
        print("Horny!")
    time.sleep(5)

I need to run this script (python3) on my raspberry pi3 (debian) in background, (like Daemon o Service) for let me know when my core be on fire!

Toni
  • 97
  • 1
  • 10
  • If you ran that as a daemon - where would you expect to see `Horny!`? Just open a terminal and run it ... – tink Nov 19 '18 at 20:10
  • I will replace "print("Horny")" for another command line (Dont worry, its a example). I need to know how could i run this script like a Daemon or Service. ;) – Toni Nov 19 '18 at 20:12
  • Again - if it's daemonised, where do you expect to see the output, independent of WHAT you output? – tink Nov 19 '18 at 20:14
  • ok @tink, i want to look "Horny!" in my terminal. – Toni Nov 19 '18 at 20:19
  • *sigh* ... so you **don't** want it in the background, then? – tink Nov 19 '18 at 20:22
  • Could i receive this warning in my terminal while the script be run in background? – Toni Nov 19 '18 at 20:25
  • @tink; when my core be hot, i run a "send email method". I am excluded this part for my script for make it most single. – Toni Nov 19 '18 at 20:30
  • check nohup: if your on *nix [Unix, Linux] there might be some Win equivalent or WSL2 or ... here`s a related q&a: https://stackoverflow.com/questions/2975624/how-to-run-a-python-script-in-the-background-even-after-i-logout-ssh – Alexander Brockmeier Apr 15 '21 at 19:20

0 Answers0