searxng / print.py
Surbao's picture
Update print.py
779b72a verified
raw
history blame
792 Bytes
import time
def read_and_print_file():
try:
with open('/etc/searxng/settings.yml', 'r') as file:
content = file.read()
print("File Content:\n", content)
except FileNotFoundError:
print("Error: File '/etc/searxng/settings.yml' not found.")
except PermissionError:
print("Error: Permission denied to read the file.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
# 定时运行
interval = 600 # 设置间隔时间(单位:秒),例如 600 秒(10 分钟)
print("Starting task. Press Ctrl+C to stop.")
try:
while True:
read_and_print_file()
print(f"Sleeping for {interval} seconds...")
time.sleep(interval)
except KeyboardInterrupt:
print("\nTask stopped.")