Daemon in background in python -


I need this script to work in the background like a daemon, so far I can only work but in the background No:

  import threading import timing, striptime import time def write_it (): #this function, typing real time in every 2 seconds in the threading file. Timer (2.0, write_it). Start () f = open ("file.txt", "a") hora = strftime ("% y-% m-% d% H:% M:% S", gmtime ()) # print edge f.write (Hora + "\ n") f.close () def non_daemon (): time.sleep (5) #print 'test non daemon' write_it () t = threading. Thread (name = 'non daemon', target = non_daemon) t.start ()   

I have already tried another way, but any work that works in the background I was looking at, any other option?

If you are looking to run a script as a daemon, then a good way to use the library You must do the following code, which you want to do:

  import daemon import time def write_time_to_file (): with open ("file.txt", "a") f: hora = time .strftime ("% Y-% m-% d% H:% M:% S", time.gmtime ()) f.write (horror + "\ n") with daemon Damon Context (): While (True):            P>

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -