Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8056855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:50:39+00:00 2026-06-05T08:50:39+00:00

I have a small python script that creates a graph of data pulled from

  • 0

I have a small python script that creates a graph of data pulled from MySQL. I’m trying to figure out a way to run the script in the background all time on a regular basis. I’ve tried a number of things:

  1. A Cron Job that runs the script
  2. A loop timer
  3. Using the & command to run the script in the background

These all have there pluses and minuses:

  1. The Cron Job running more then every half hour seems to eat up more resources then it’s worth.
  2. The Loop timer put into the script doesn’t actually put the script in the background it just keeps it running.
  3. The Linux & command backgrounds the process but unlike a real Linux service I can’t restart/stop it without killing it.

Can someone point me to a way to get the best out of all of these methods?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:50:40+00:00Added an answer on June 5, 2026 at 8:50 am

    Why don’t you try to make your script into a proper daemon. This link is a good place to start.

    import os
    import subprocess
    import time
    from daemon import runner
    
    class App():
        def __init__(self):
            self.stdin_path = '/dev/null'
            self.stdout_path = '/dev/tty'
            self.stderr_path = '/dev/tty'
            self.pidfile_path =  '/tmp/your-pid-name.pid'
            self.pidfile_timeout = 5
        def run(self):
    
            try:
                while True:
    
                    ### PUT YOUR SCRIPT HERE ###
    
                    time.sleep(300)
    
            except Exception, e:
                raise
    
    app = App()
    daemon_runner = runner.DaemonRunner(app)
    daemon_runner.do_action()
    

    You can start/stop/restart this script just like any other linux service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small python cgi script that accepts an image upload from the
I have a small in-house Python script for Linux that creates a /home/user/environ_script.sh file
I currently have a small Python script that I'm using to spawn multiple executables,
I have small web app that generate PDF files as a report. I'm trying
I would like to build a small python script that basicaly does the reverse
I have a small shell script in a string inside my python file. Now
I have a small python script which serves as a configuration file. The structure
I've written a small script in Python that pings all subnets of my school's
I wrote a small-ish Python script that handles nightly conversions and archiving of audio
So I wrote a small python script that allows me to specify some folder

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.