Ubuntu apt-get problem “KEYEXPIRED: The following signatures were invalid”

apt-get update Problem

Ign:11 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 InRelease
Hit:12 https://repos.sonar.digitalocean.com/apt main InRelease
Hit:13 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 Release
Err:17 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 Release.gpg
The following signatures were invalid: KEYEXPIRED 1544811256
Fetched 1930 kB in 3s (601 kB/s)
Reading package lists… Done

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 Release: The following signatures were invalid: KEYEXPIRED 1544811256

W: Failed to fetch https://repo.mongodb.org/apt/ubuntu/dists/xenial/mongodb-org/3.6/Release.gpg The following signatures were invalid: KEYEXPIRED 1544811256
W: Some index files failed to download. They have been ignored, or old ones used instead.

Step 1: Find the Expired key
sudo apt-key list | grep -A 1 expired

Step 2: Renew the Expired key
sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys
, the one you copied from above

Step 3:
sudo apt-get update

Create Service For Apache Tomcat

cd /etc/systemd/system
sudo vi tomcat.service 
then insert following lines - 


[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

#User=tomcat
#Group=tomcat
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target




sudo systemctl daemon-reload
Start tomcat
sudo systemctl start tomcat.service

Stop tomcat
sudo systemctl stop tomcat.service

Restart tomcat
sudo systemctl restart tomcat.service

Enable service after restart automatic tomcat start
sudo systemctl enable tomcat.service


Install apache tomcat 9 in ubuntu 18.04

  • cd /tmp
  • curl -O https://downloads.apache.org/tomcat/tomcat-9/v9.0.37/bin/apache-tomcat-9.0.37.zip
  • sudo mkdir -p /opt/tomcat
  • unzip apache-tomcat-9.0.37.zip
  • rm -rf apache-tomcat-9.0.37.zip
  • mv apache-tomcat-9.0.37/* /opt/tomcat/
  • cd /opt/tomcat
  • sudo chmod -R 0777 /opt/tomcat
  • sudo update-java-alternatives -l
  • OUTPUT – java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64

  • Then Create a system service
  • Click Here