How do I freeze a Python application

Stop the python program cleanly with init.d

  • Good day,

    on my Raspi I have the octopi image running.

    My Python program controls the LEDs via the octoprint API. I start it with the init.d script below.

    I have two questions:

    a) I want to stop exactly my Python program, not all Python3 programs. How do I find the associated TaskID and how do I stop it based on this?

    b) At START I have to call with sudo (as well as in the command line). How can I get around this as a user pi?

    Display More

    Thank you for your support.

    LG superbike

  • Display More
  • Sorry! I shouldn't have been so brief.

    A PID is not necessary when using pkill, it's more about names. >> https://wiki.ubuntuusers.de/pkill/

    To the second question I can only ask counter questions due to the lack of octoprint and printer: What does the script need root rights for and what does the code look like?

  • To the second question, due to the lack of octoprint and printer, I can only ask counter questions: What does the script need root rights for and what does the code look like?

    Extract source code:

    Display More

    without sudo rights in the command line I get:

    with sudo in advance it runs wonderfully.

    Thank you for your help.

    LG superbike

  • Hmm You shortened that in the script.

  • ... sorry, / dev / mem is not in my script, has to be in an imported one ...

  • Imho doesn't really seem to have a good solution for this, maybe someone else has an idea.

  • The whole thing seems like a huge project.

    / dev / mem ??? that the whole thing seems to be highly complex :-)

    Is / dev / mem what I think what this is is the working memory ??

    The whole thing seems to have a hacking routine, make sure it doesn't phone home :-) :-)

    Is that really a 3D printer software ???

  • ... be careful not to call home :-)

    even worse: I can even get pictures from the 3D printer via Telegram on the mobile phone

  • Hello,

    I start it with the init.d script below.

    You know that this is out of date and that systemd has been the state of the art for a long time? init.d is only available for "legacy" reasons.

    Greetings, noisefloor

  • I can say that dropbear (ssh) creates an init.d (dingsbums).

    But the kicker is with systemctl stop dropbear it is stopped.

    Of course, if I do NOSTAR = NO in / etc / default / dropbear.

    Openssh via systemctl disable and dropbear enable, dropbear also runs without the "systemctl" service.

  • Hello,

    Openssh via systemctl disable and dropbear enable, dropbear also runs without the "systemctl" service.

    The sentence makes no sense in terms of content ... systemd is the init system at Raspbian, it controls everything. What is in init.d is also carried out by systemd by creating a systemd unit "on the fly".

    systemctl is the command line tool for interacting with systemd.

    Greetings, noisefloor

  • yes're right.

    But do you have a tip how to write something with echo in a file that belongs to root: root.

    I do it mercilessly (with original password) :-)

    echo "$ pword" | sudo -S sh -c 'echo "hello"> "this file belongs to.root"'

    These are things that move the world, how can you ask something like that :-)

    greetings