[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to force chronyd to be online after booting



> On 09/26/2014 06:31 PM, lee wrote:
>> is there an easy way to force chronyd to get into/remain in its online
>> mode rather than going into offline mode?

I had the same problem. My workaround was to run the following python
script from /etc/cron.hourly/

#! /usr/bin/env python

import os
import time

def main():
    chronyd_running = False
    for line in os.popen("ps -ef", "r").readlines():
        if "/usr/sbin/chronyd" in line:
            chronyd_running = True
    sources_ok = False
    if chronyd_running:
        for line in os.popen("chronyc sources", "r").readlines():
            if line.startswith("^") and "10y" not in line:
                sources_ok = True
    if not sources_ok:
        os.system("/etc/init.d/chrony stop")
        time.sleep(3)
        os.system("/etc/init.d/chrony start")

if __name__ == "__main__": main()

--
Dieter Deyke
mailto:dieter.deyke@gmail.com


Reply to: