[FIX] Interrupt service script on reboot


My knowledge in this field is limited, so please excuse my ignorance and stupidity.

I’ve used these two questions/solutions (first and second) to create a .service that will run a python script when a linux OS computer restarts. The first time I tried this was on a AWS EC2 machine and I ended up screwing myself with how I set it up. I had to completely scrap my work and start over. Within my python script I had something that would reboot the computer, and naturally once on reboot, the .service would be triggered. So essentially I kept restarting my computer. Unfortunately I could not execute sudo systemctl stop myscript.service before the computer would restart. So I was locked out of my computer. Never made that mistake again….

Looking back at it now and to avoid accidently getting into that situation again, how might I stop that specific .service from running? Is there a way to access the command line before “fully” rebooting? Or would I need to fully reinstall ubuntu? I’m also interested in suggestions for how others would set up a system like this.

For simplicity sake this is what I had:

Description=Some kind of description

ExecStart= /home/ubuntu/anaconda3/envs/post/bin/python3.8 /home/ubuntu/myPythonScript.py


import os


Click Here to see answer

payam 2 weeks 2022-09-21T20:34:18+00:00 0 Answers 0 views

Leave an answer

By answering, you agree to the Terms of Service and Privacy Policy.