# How to correctly add auto-renewal (Debian 9 (Stretch))

**URL:** <https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775>\
**Category:** Help\
**Created:** [November 7, 2019, 10:40am UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775 "2019-11-07T10:40:11Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [November 7, 2019, 12:12pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/21 "2019-11-07T12:12:54Z")

</div>

OK, let’s try just that one cert:

```auto
sudo /usr/local/sbin/certbot-auto renew --apache --cert-name elami.mk --deploy-hook '/etc/init.d/apache2 restart'

```

I think I found MY MISTAKE - was missing “renew” in command.

---

<div class="post-metadata">

**Author:** ![TheErminK](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/theermink/32/33988_2.png) [@TheErminK](https://community.letsencrypt.org/u/TheErminK)\
**Post date:** [November 7, 2019, 12:14pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/22 "2019-11-07T12:14:32Z")

</div>

> [@rg305](#):
>
> OK, let’s try just that one cert:
> 
> ```nohighlight
> 
> ```

sudo /usr/local/sbin/certbot-auto --apache --cert-name elami.mk --deploy-hook '/etc/init.d/apache2 restart'  
Saving debug log to /var/log/letsencrypt/letsencrypt.log  
Plugins selected: Authenticator apache, Installer apache  
Cert not yet due for renewal

You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.  
(ref: /etc/letsencrypt/renewal/elami.mk.conf)

What would you like to do?

* * *

1: Attempt to reinstall this existing certificate  
2: Renew & replace the cert (limit ~5 per 7 days)

* * *

Select the appropriate number [1-2] then [enter] (press 'c' to cancel):

What do I click ?

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [November 7, 2019, 12:15pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/23 "2019-11-07T12:15:07Z")

</div>

press C

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [November 7, 2019, 12:16pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/24 "2019-11-07T12:16:05Z")

</div>

I think I found MY MISTAKE - was missing “renew” in command.

Let’s try it with “renew”:

```auto
sudo /usr/local/sbin/certbot-auto renew --apache --deploy-hook '/etc/init.d/apache2 restart'

```

---

<div class="post-metadata">

**Author:** ![TheErminK](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/theermink/32/33988_2.png) [@TheErminK](https://community.letsencrypt.org/u/TheErminK)\
**Post date:** [November 7, 2019, 12:17pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/25 "2019-11-07T12:17:03Z")

</div>

> [@rg305](#):
>
> Let’s try it with “renew”:

sudo /usr/local/sbin/certbot-auto renew --apache --deploy-hook '/etc/init.d/apache2 restart'  
Saving debug log to /var/log/letsencrypt/letsencrypt.log

* * *

Processing /etc/letsencrypt/renewal/elami.mk.conf

* * *

Cert not yet due for renewal

* * *

Processing /etc/letsencrypt/renewal/justsayingkiddo.nl.conf

* * *

Cert not yet due for renewal

* * *

Processing /etc/letsencrypt/renewal/kentivo.de.conf

* * *

Cert not yet due for renewal

* * *

Processing /etc/letsencrypt/renewal/www.kentivo.de.conf

* * *

Cert not yet due for renewal

* * *

The following certs are not due for renewal yet:  
/etc/letsencrypt/live/elami.mk/fullchain.pem expires on 2019-12-10 (skipped)  
/etc/letsencrypt/live/justsayingkiddo.nl/fullchain.pem expires on 2019-12-10 (skipped)  
/etc/letsencrypt/live/kentivo.de/fullchain.pem expires on 2019-12-12 (skipped)  
/etc/letsencrypt/live/www.kentivo.de/fullchain.pem expires on 2019-12-12 (skipped)  
No renewals were attempted.  
No hooks were run.

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [November 7, 2019, 12:18pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/26 "2019-11-07T12:18:25Z")

</div>

Perfect !

Now we just need to add that command to CRON so that is runs automatically.

---

<div class="post-metadata">

**Author:** ![TheErminK](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/theermink/32/33988_2.png) [@TheErminK](https://community.letsencrypt.org/u/TheErminK)\
**Post date:** [November 7, 2019, 12:19pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/27 "2019-11-07T12:19:16Z")

</div>

> [@rg305](#):
>
> Now we just need to add that command to CRON so that is runs automatically.

Amazing!  
You are the best!  
EDIT: I read about CRON (the link you provided) I get what it does.

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [November 7, 2019, 12:20pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/28 "2019-11-07T12:20:02Z")

</div>

One last check:  
Let’s make sure the “restart” will work when called:  
Try:  
`sudo /etc/init.d/apache2 restart`

---

<div class="post-metadata">

**Author:** ![TheErminK](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/theermink/32/33988_2.png) [@TheErminK](https://community.letsencrypt.org/u/TheErminK)\
**Post date:** [November 7, 2019, 12:21pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/29 "2019-11-07T12:21:11Z")

</div>

> [@rg305](#):
>
> Try:  
> `sudo /etc/init.d/apache2 restart`

sudo /etc/init.d/apache2 restart  
[ok] Restarting apache2 (via systemctl): apache2.service.

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [November 7, 2019, 12:21pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/30 "2019-11-07T12:21:51Z")

</div>

Perfect!  
Cheers from Miami 🙂

---

<div class="post-metadata">

**Author:** ![TheErminK](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/theermink/32/33988_2.png) [@TheErminK](https://community.letsencrypt.org/u/TheErminK)\
**Post date:** [November 7, 2019, 12:24pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/31 "2019-11-07T12:24:35Z")

</div>

Thank you very much, please provide a patreon link or something similar you use 🙂

Also wanted to ask, is there like a default cron command I can copy paste into cron so it does the trick ?  
The tutorials online say start moving certbot here and there… simply doesn’t sound good.

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [November 7, 2019, 12:29pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/32 "2019-11-07T12:29:38Z")

</div>

> [@TheErminK](#):
>
> please provide a patreon link or something similar you use

You can [buy me a beer](https://beer4.work/) or simply donate to LE: [Support Encryption for Everyone - Let's Encrypt](https://letsencrypt.org/donate/)

> [@TheErminK](#):
>
> is there like a default cron command I can copy paste into cron so it does the trick ?

I gave you a starting point entry earlier:

> [@rg305](#):
>
> 41 \*/12 \* \* \* /usr/local/sbin/certbot-auto --apache -q --deploy-hook '/etc/init.d/apache2 restart'

Don't forget to mark this topic "solved".

---

<div class="post-metadata">

**Author:** ![TheErminK](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/theermink/32/33988_2.png) [@TheErminK](https://community.letsencrypt.org/u/TheErminK)\
**Post date:** [November 7, 2019, 12:34pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/33 "2019-11-07T12:34:03Z")

</div>

> [@rg305](#):
>
> > 41 \*/12 \* \* \* /usr/local/sbin/certbot-auto --apache -q --deploy-hook ‘/etc/init.d/apache2 restart’

should I maybe change this and enter it in cron like this?

```
41 */12 * * * /usr/local/sbin/certbot-auto renew --apache --deploy-hook '/etc/init.d/apache2 restart'

```

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [November 7, 2019, 12:36pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/34 "2019-11-07T12:36:01Z")

</div>

When run with “-q” it will only “renew”…So they are basically the same.

If you want to go ALL OUT (or ALL IN) use:  
**`renew -n -q`**

```auto
41 */12 * * * /usr/local/sbin/certbot-auto renew -n -q --apache --deploy-hook '/etc/init.d/apache2 restart'

```

---

<div class="post-metadata">

**Author:** ![TheErminK](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/theermink/32/33988_2.png) [@TheErminK](https://community.letsencrypt.org/u/TheErminK)\
**Post date:** [November 7, 2019, 12:46pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/35 "2019-11-07T12:46:29Z")

</div>

> [@rg305](#):
>
> > 41 \*/12 \* \* \* /usr/local/sbin/certbot-auto --apache -q --deploy-hook ‘/etc/init.d/apache2 restart’

Just out of curiosity, does this crone command ecexute every day at every 12 hours on the 41st minute ?

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [November 7, 2019, 12:54pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/36 "2019-11-07T12:54:58Z")

</div>

YES  
00:41 & 12:41  
everyday

---

<div class="post-metadata">

**Author:** ![TheErminK](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/theermink/32/33988_2.png) [@TheErminK](https://community.letsencrypt.org/u/TheErminK)\
**Post date:** [November 7, 2019, 12:56pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/37 "2019-11-07T12:56:01Z")

</div>

Thank you a lot again!

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [November 7, 2019, 12:56pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/38 "2019-11-07T12:56:44Z")

</div>

You can thank me in 2 days when it renews your first cert (automatically) - LOL

> [@TheErminK](#):
>
> Certificate Name: elami.mk  
> Domains: elami.mk www.elami.mk  
> Expiry Date: 2019-12-10 10:18:04+00:00 (VALID: 32 days)

Or, better yet, thank LE (for **all** they do)

---

<div class="post-metadata">

**Author:** ![TheErminK](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/theermink/32/33988_2.png) [@TheErminK](https://community.letsencrypt.org/u/TheErminK)\
**Post date:** [November 7, 2019, 1:03pm UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/39 "2019-11-07T13:03:52Z")

</div>

Yes definitely will donate again and thanks to every one of you working for all of us here, it is really appreciated around the globe. Hope you realize that.

I added the cron job using crontab -e  
got this  
crontab -e  
no crontab for root - using an empty one  
GNU nano 2.7.4 File: /tmp/crontab.IynLJ2/crontab Modified

daemon’s notion of time and timezones.

Output of the crontab jobs (including errors) is sent through  
email to the user the crontab file belongs to (unless redirected).

For example, you can run a backup of all your user accounts  
at 5 a.m every week with:  
0 5 \* \* 1 tar -zcf /var/backups/home.tgz /home/

For more information see the manual pages of crontab(5) and cron(8)

m h dom mon dow command

41 \*/12 \* \* \* /usr/local/sbin/certbot-auto renew --apache --deploy-hook ‘/etc/init.d/apache2 restart’  
^^^^

Added this

---

<div class="post-metadata">

**Author:** ![TheErminK](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/theermink/32/33988_2.png) [@TheErminK](https://community.letsencrypt.org/u/TheErminK)\
**Post date:** [November 8, 2019, 12:56am UTC](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775/40 "2019-11-08T00:56:19Z")

</div>

> [@rg305](#):
>
> YES  
> 00:41 & 12:41  
> everyday

I hate to bother you again, but I waited for 00:41 just to see if the job will run and if everything will be alright, and the job did not run 😕 Can we check it somehow ?  
I used the command crontab -e  
it was first time using it so I selected nano editor  
I added the following code

` 41 */12 * * * /usr/local/sbin/certbot-auto renew --apache --deploy-hook '/etc/init.d/apache2 restart'`

It created the new cron

`crontab: installing new crontab`

Also when I run systemctl list-timers -all

```
NEXT LEFT LAST PASSED UNIT
Fri 2019-11-08 01:09:00 UTC 13min left Fri 2019-11-08 00:39:01 UTC 16min ago phpsessionclean.timer
Fri 2019-11-08 06:08:13 UTC 5h 12min left Thu 2019-11-07 21:01:59 UTC 3h 53min ago apt-daily.timer
Fri 2019-11-08 06:11:31 UTC 5h 15min left Thu 2019-11-07 06:04:35 UTC 18h ago apt-daily-upgrade.timer
Fri 2019-11-08 14:47:11 UTC 13h left Thu 2019-11-07 14:47:11 UTC 10h ago systemd-tmpfiles-clean.ti

```

this is all of them from before, I suspect my cron should have been added ?

Thank you again sorry for bothering.

[Previous page](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775.md?page=1)

[Next page](https://community.letsencrypt.org/t/how-to-correctly-add-auto-renewal-debian-9-stretch/105775.md?page=3)
