Edit your crontab by typing crontab -e and then add the following line.
0 6 * * * certbot renew --post-hook "systemctl restart lsws"
In my example, I am restarting Litespeed, but you could restart Nginx or Apache by changing it like this:
0 6 * * * certbot renew --post-hook "systemctl restart nginx"
0 6 * * * certbot renew --post-hook "systemctl restart apache2"
This will check your certificates every day at 06:00 and renew it if necessary. Once it’s renewed, it will restart your web server so that the new certificate takes effect.