I have a python Daemon that runs continuously and hopefully never stops. It's being monitored by supervisord. However when the current date switches to the following day the following variable stays as yesterday's date:

today = datetime.date.today().strftime("%Y%m%d") 

Any ideas on how to correct this and make the date keep up? The current workaround is to schedule a cron task to restart the service and it grabs the new date. Even though that takes a few seconds it could interrupt the users so I want to come up with a better solution.

3

1 Answer

Variable assignments don't auto-magically update themselves.

Why not simply re-run the statement you showed each time you might need to refer to the current date? Or perhaps on each pass through your main loop, if you're referring to it thousands of times a second and repeated calls might degrade performance.

2

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