# Automated renewals

Before starting test that the renewal process works

```bash
/opt/letsencrypt/letsencrypt-auto renew --dry-run
```

Make sure the path is accessible from cron

```bash
 sudo chmod go+x /etc/letsencrypt/archive
 sudo chmod go+x /etc/letsencrypt/live
```

Make a script file

```bash
sudo nano /usr/bin/tsrefreshcerts.sh
```

.... containing the following commands

```bash
/opt/letsencrypt/letsencrypt-auto renew
cd /etc/letsencrypt/live/letsencrypt.tempusserva.dk
openssl pkcs12 -export -out bundle.pfx -inkey privkey.pem -in cert.pem -certfile chain.pem -password pass:TempusServaSecret
/usr/bin/tstomcatrestart.sh
```

Now add a job to the crontab

```bash
 sudo crontab -l > tempcron
 echo "0 0 1 * * /usr/bin/tsrefreshcerts.sh" >> tempcron
 sudo crontab tempcron
 rm tempcron
```

### <span id="bkmrk-"></span><span class="mw-headline" id="bkmrk-problems-with-amazon-1">Problems with Amazon Linux?</span>

In case the autorenewal process fails try updating the dependencies and pip

```bash
 sudo /opt/eff.org/certbot/venv/bin/pip2 install cryptography zope interface 
 sudo /opt/eff.org/certbot/venv/bin/pip2 install --upgrade pip
 sudo rsync -avz /opt/eff.org/certbot/venv/lib64/python2.7/dist-packages/ /opt/eff.org/certbot/venv/lib/python2.7/dist-packages/
```

### <span id="bkmrk--2"></span><span class="mw-headline" id="bkmrk-still-got-problems-w-1">Still got problems with Amazon Linux?</span>

In case certbot cant find the root folder try and run it manually

```bash
 sudo /opt/letsencrypt/letsencrypt-auto certonly
```

Choose the following values when prompted

```
 2: Place files in webroot directory (webroot)
 <domain>  
 2: Renew & replace the cert (may be subject to CA rate limits)
 /usr/share/tomcat7/webapps/ROOT/
```

### <span id="bkmrk--4"></span><span class="mw-headline" id="bkmrk-need-manual-crontab--1">Need manual crontab install?</span>

Steps

- sudo crontab -e
- press INSERT
- move to bottom of file
- paste this

```bash
  0 0 1 * * /usr/bin/tsrefreshcerts.sh
```

- press ESC
- press :wq