I am trying to run this particular shell script only one time, daily. Here's my code for runLucene.py
:
#!/usr/bin/env python
import os
from extras.download_datos_desambiguar import news_Lucene
x=datetime.today()
y=x.replace(day=x.day, hour=09, minute=00, second=0, microsecond=0)
delta_t=y-x
secs=delta_t.seconds+1
def fourdlife():
print "checking function"
os.system("~/code/4dlife_repo/4dbatch/src/engines/extras/download_datos_desambiguar/news_Lucene.py")
t = Timer(secs, fourdlife)
t.start()
print "timer started"
I am running this code in my ProcesosContinuous.py
file like this:
while True:
os.system("./runl.sh")
#some other processes
where runl.sh
is
python ~/code/4dlife_repo/4dbatch/src/engines/extras/download_datos_desambiguar/news_Lucene.py
This python code is always running on my apache2
server.
However, this is working at any given hour and not just the specified hour. What am I doing wrong?
Also, I feel there is a much better way to do this. I looked at the cron
task but that's not what I am looking for. I don't want my program to go to sleep()
because I need the other processes to run after the runl.sh
process. What is the best way to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…