How do I create a python daemon in Windows?

I want to create a python daemon in windows named daemon.py.

There is a file a.py which is used to take backup. I want to run this file every hour as background process. After one hour this daemon.py automatically should call a.py and then again after each hour it should do the same.

Also this daemon needs to be running the whole time. If by mistake user deleted this daemon process, it should start automatically & also it should start automatically after the start of the window.

I have tried many cases but not able to yet get the proper code.

Can anyone help me in solving this please?

2 Answers

As bubu suggests, consider Windows Task Scheduler. While crond is available, Task Scheduler is already there and part of Windows.

Use the Task Scheduler Windows UI to set this up or your script(s) may use the command line. Schedule and manage tasks with the at command.

With TS, schedule your daemon script to execute every hour. There are also settings available that will cause the task to run if it fails.

Good luck.

one of the way to do it would be to use the task scheduler in windows. the downside of it is that it is not as flexible as cron daemon in unix. for example, you can't specify per hour activity.

another way of doing it, which i recommend, is to use crond for windows. () ask here if you have trouble setting it up

EDIT: task scheduler can specify per hour, or even per minute behavior. it's just that i haven't looked hard enough. thanks for pointing out.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like