Files
fcb-ai-db-sync/cron.py
2025-01-22 10:39:33 +08:00

24 lines
751 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from datetime import datetime, timedelta
from time import sleep, time
import fcbsync_dbphoto_mysql
if __name__ == '__main__':
while 1:
if datetime.now().hour >= 8 and datetime.now().hour < 18:
# 白天间隔10分钟
sleep_time = 10 * 60
else:
# 夜间间隔20分钟
sleep_time = 20 * 60
# 执行同步
start_time = time()
fcbsync_dbphoto_mysql.main()
end_time = time()
elapsed_time = end_time - start_time
if elapsed_time > 30:
print('警告执行时间超过30秒请检查程序运行状态')
print(f'下一次同步时间:{datetime.now() + timedelta(seconds=sleep_time)}')
sleep(sleep_time)