7

Man I feel sort of stupid. OK so I have a python script that needs to be kept running 24/7 but my laptop's screen cant be on 24/7 and locks. How do I make sure my python script comtimues to run? It is an ubuntu machine btw.

Comments
  • 1
    Depending on why it needs to be running 24/7, you could set up a cron job
  • 3
    @zacg *smacks own forehead* whoops shoulda thought of that.
  • 1
  • 2
    @ThaOneDude Write a daemon script - if you're on Ubuntu, hook into systemctl and start the script as a service in the background.
  • 1
    See here for running a CLI process in the background: https://scottlinux.com/2014/12/...
  • 2
    ... so many questions ...
  • 1
    @Froot I gotta keep it very hush hush.
  • 3
    @ThaOneDude Hehe that's fine.
    It's still going to keep running when your screen locks.

    > If it's something you don't need to interact with just chuck it in Cron with @reboot and you can be sure it's always running when your computer is.

    > Otherwise you could just open a terminal window and run it there.

    > If you want to run it manually but on the background, put an & at the end of the command.

    Edit: Oh hai @reboot. Didn't mean to pull you into this 😄
  • 1
    daemon?
    If not: Screen, Tmux.

    For absolute overkill on making sure it's still alive, run a check/restart script every so often via a cron.
  • 2
    @Froot I didn't know about the ? at the end of the command - I'll have to try that sometime
Add Comment