Skip to content

Instantly share code, notes, and snippets.

@syuu1228
Created April 14, 2023 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syuu1228/c80a7fba743194c6601fb83542932d92 to your computer and use it in GitHub Desktop.
Save syuu1228/c80a7fba743194c6601fb83542932d92 to your computer and use it in GitHub Desktop.
ec2_configure_chrony.py
#!/usr/bin/python3
import re
with open('/etc/chrony/chrony.conf') as f:
chrony_conf = f.read()
chrony_conf = re.sub(r'^(pool .*$)', '# \\1', chrony_conf, flags=re.MULTILINE)
with open('/etc/chrony/chrony.conf', 'w') as f:
f.write(chrony_conf)
with open('/etc/chrony/sources.d/ntp-pool.sources', 'w') as f:
f.write('pool time.aws.com iburst\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment