2025-06-27 16:56:03 -06:00

23 lines
543 B
Python
Executable File

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""A simple Python script to output the current date and time as a JSON object string every 0.5 seconds.
Used instead of the `date` command in order to avoid spawning a new process every 0.5 seconds.
"""
import datetime
import sys
import time
def get_date():
"""Return the current date as a JSON object string."""
return int(datetime.datetime.now().timestamp())
if __name__ == "__main__":
while True:
print(get_date())
sys.stdout.flush()
time.sleep(0.5)