Auto Restart LSWS When Certbot Renews?

I have a number of droplets running OpenLiteSpeed Wordpress. By default, the Letsencrypt certificate SSL appears to renew itself automatically near expiry.

This is different to what I have done in the past with some Apache servers, where I get an expiry notice by email from Letsencrypt and I either have to manually renew using certbot renew or set up a crontab.

However it seems I have to restart the LSWS service for the renewal to take effect.

What would be the best way to automatically apply the renewed certificate? Is there some sort of openlitespeed setting somewhere? Or do I need some potentially-dodgy* cron that restarts the lsws service on the first day of every month?

Kind Regards

*not keen on things like scheduled service restarts especially things like web services that might somehow fail to start again

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


The image comes with automatic certificate renewal by default in /etc/cron.d/certbot. Once you finish the Let’s Encrypt apply by prompt script, it will auto-apply the server hook to the cronjob rule. An example of the cron job is:

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew --deploy-hook "systemctl restart lsws"

What if the Certbot Deploy Hook is not Triggered?

If your certificate renewal is successful, but for some reason, the deploy hook is not being triggered, you can run the following command. This will insert a restart lsws command into the Certbot cronjobs.

echo '0 0 * * 3 root systemctl restart lsws' | sudo tee -a /etc/cron.d/certbot > /dev/null

This particular example triggers a web server restart every Wednesday at Midnight. You can modify the 0 0 * * 3 part of the command to adjust the schedule, if needed.

Note, the web server restart will not cause any downtime.


Hi Matt,

Letsencrypt should usually update itself. However you can check out Quick Install SSL with Let’s Encrypt where it clearly explains how to configure it for different operating systems.

Hope that helps you,

Sergio Turpín