from pathlib import Path
import time
from datetime import datetime

while True:
    now = datetime.now()
    file = open(Path(__file__).with_name('MyExternalOscillatorSignal.txt'), 'w')
    file.write(str(int(round(now.timestamp()))))
    file.close()
    print("MyExternalOscillatorSignal.txt update -> ", str(now))
    time.sleep(2)