I have a script with GPIO.event_detected(port) to count number of times a hall effect sensor is initiated. My script works amazing when executed in python3 IDLE run module. Counts are accumulated per datetime.datetime.now().

When I execute the script in terminal shell, I only receive 1 total count per timestamp; maximum 2 or 3 if I blow hard into hall effect sensor. Why do my counts vary when executed in shell vs. IDLE? I have a while loop within the script to basically sum up each count per datetime.datetime.now(). Again works perfect in IDLE module execute but not in terminal shell. Is this because the shell is not fast enough to count GPIO counts?

What I am trying to achieve is have my script run on startup in rc.local. Is it possible to execute a python3 script in IDLE run module during startup? So it shows the python 3.4.2 shell view and runs?

  • 2
    If you want help you need to supply a code listing. You are asking us to guess which is a waste of our time.
    – joan
    Commented Jun 3, 2018 at 9:54

1 Answer 1


Easy. Make a executable file, which executes the following command:
/usr/bin/idle3 -r <**YOUR_FILE_PATH**>
And move it to rc.local
If your script has to be run as root, just put sudoin front onf the command.

  • 1
    First: rc.local is running with root rights, so never use an additional sudo within it. Second: Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. We have seen many problems here on this site using it. Following the recommendation of the developers from systemd you should avoid using it.
    – Ingo
    Commented Nov 3, 2019 at 10:15
  • @ingo : thanks for the warning. Is there a safer alternative? Commented Feb 25, 2021 at 2:22
  • I also got smarter in the last years: It is advisable to create a systemd service instead like show here linuxconfig.org/how-to-create-systemd-service-unit-in-linux
    – itzFlubby
    Commented Feb 26, 2021 at 10:52
  • @DenisCousineau as noted in Compatibility with SysV. and also suggested by @itzFlubby above you should use systemd Unit files. You will find many examples here looking at tag systemd.
    – Ingo
    Commented Feb 27, 2021 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.