I sincerely appreciate the information and your patience.
you make a great point about the times,
and I will be changing it.
When I began using certbot, the crontab recommendation was not so refined or clear.
I know what you mean about everybody running jobs at midnight, I used to work in hosting.
I moved mine to be polite to you.
As far as the frequency, that is intentional. From a system perspective, certbot itself could fail,
and cause other problems. I have seen "croinjobs gone wild" too may times.
I like the deploy-hooks, I had no idea it was available.
this is what I've been using on another box.
#!/usr/bin/env python3
import socket, ssl, subprocess, sys, time
cert_host= sys.argv[1]
cert_port = int(sys.argv[2])
cert_services= [ ['pkill','-HUP','sendmail'],
['/usr/local/sbin/dovecot' ,'reload'],
['/usr/local/sbin/nginx', '-s', 'reload']
]
certbot_cmd = ['certbot', 'renew']
context = ssl.create_default_context()
conn = context.wrap_socket(socket.socket(socket.AF_INET)
,server_hostname= cert_host)
try:
conn.connect((cert_host, cert_port))
cert = conn.getpeercert()
timestamp = ssl.cert_time_to_seconds(cert['notAfter'])
days_left= (timestamp - time.time()) / 86400
if days_left > 11:
print( 'The Cert was not renewed,')
print(f'it is valid until {cert["notAfter"]}')
else:
subp=subprocess.run(certbot_cmd)
[subprocess.run(srv) for srv in cert_services]
except:
print(f'unable to get cert from host {cert_host} on port {cert_port}')
This is the oldest certbot log on that server
-rw-r--r-- 1 root wheel 755B Jan 29 2019 letsencrypt.log.203
You should take that as compliment.
I haven't had to give it much attention at all. I forget it's even there .
I really appreciate you taking the time to reply, thank you.
Adrian