|
import os |
|
import time |
|
|
|
def read_and_print_file(): |
|
filepath = '/etc/searxng/settings.yml' |
|
if not os.path.exists(filepath): |
|
print(f"Error: {filepath} does not exist.") |
|
return |
|
try: |
|
with open(filepath, 'r') as file: |
|
content = file.read() |
|
print("File Content:\n", content) |
|
except PermissionError: |
|
print(f"Error: Permission denied to read {filepath}.") |
|
except Exception as e: |
|
print(f"An unexpected error occurred: {e}") |
|
|
|
|
|
interval = 10 |
|
print("Starting task to print file content. Press Ctrl+C to stop.") |
|
try: |
|
while True: |
|
read_and_print_file() |
|
time.sleep(interval) |
|
except KeyboardInterrupt: |
|
print("\nTask stopped.") |