Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I understood that I can create a service that would run and perform certain tasks in the background. But I actually only need to execute a task that needs to be done every 5 minutes. It needs not to run in between.

Now I was thinking that it may be a better idea to have a crontab entry that runs the (python) download script every 5 minutes. I am new to Linux and may have an incorrect understanding of what cron is for and what good practices are, but to me it seems as if this is a much more stable way because if the script would halt for any reason it will just be re-run.

What would be the recommended approach in that case? A (well-behaved) daemon that waits 5 minutes, or a cron that runs a script that just stops when done.

share|improve this question
    
daemons are for things that need an instant responce when something happens (like a command or a request etc). If you need something every 5 minutes .... cron! –  Rinzwind Nov 25 '11 at 19:52

1 Answer 1

up vote 5 down vote accepted

Cron is the answer for this problem no doubt. The daemon would be needed if you have something that requires sub-minute wake up times or is completely event driven. If you have something that needs to run every 5 minutes you should schedule it with Cron and avoid all the daemon complexities. One thing that I would suggest looking into would to have a lock that will prevent the scripts from running more then one instance at a time.

share|improve this answer
    
Both you and Rinzwind made me so happy with that answer! I had to built the same application for Android before. So much less reliable and endlessly more complex to achieve the same thing. (Probably the result of how much I like Java not) –  Ruud Nov 25 '11 at 21:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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