How do I write a non-stop crawler using python and run it on the server?
1 answer
What you want to do is demo the process. This will be useful when creating a daemon.
Demonstrating the process will allow it to run in the background, so as long as the server is running (even if the user is not logged in) it will continue to run.
Here is an example daemon that writes time to a file.
import daemon
import time
def do_something():
while True:
with open("/tmp/current_time.txt", "w") as f:
f.write("The time is now " + time.ctime())
time.sleep(5)
def run():
with daemon.DaemonContext():
do_something()
if __name__ == "__main__":
run()
+3
source to share