Ubuntu Service Autostart

vi /etc/systemd/system/mongodb.service

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

systemctl start mongodb systemctl enable mongodb

vi /etc/systemd/system/elastic.service

[Unit]
Description=Port forwarding for 9200
After=network.target

[Service]
User=javelin
ExecStart=/usr/bin/ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -R 9201:15.0.33.22:9200 user@host.com
RestartSec=3
Restart=always

[Install]
WantedBy=multi-user.target

systemctl start elastic

systemctl enable elastic

https://blog.kylemanna.com/linux/ssh-reverse-tunnel-on-linux-with-systemd/

linux @blog