Monitoring services and starting them on boot --------------------------------------------- From wikipedia > Systemd is a software suite that provides fundamental building blocks for a Linux operating system. It includes the systemd “System and Service Manager”, an init system used to bootstrap user space and manage user processes. systemd aims to unify service configuration and behavior across Linux distributions. Before going gaga over **systemd** checkout [arguments against](http://without-systemd.org/wiki/index.php/Arguments_against_systemd) it as well. But personally I find it easy to manage. Since I am not well versed in Linux it helps me make less blunders and miss out on doing some things because of lazyness and unfamiliarity. I use a command called **systemctl.** Check if it is supported in your Linux Distro or not. \# which systemctl /bin/systemctl ### Handy Commands Start an application sudo systemctl start application#Examplesudo systemctl start nginx Stop an application sudo systemctl stop application#Examplesudo systemctl stop nginx Restart an application sudo systemctl restart application#Examplesudo systemctl restart nginx Reload an application sudo systemctl reload application#Examplesudo systemctl reload nginx Check status sudo systemctl status application#Examplesudo systemctl status nginx Example output of status **●** nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: **active (running)** since Wed 2019-01-30 11:29:16 IST; 1 weeks 0 days ago Docs: man:nginx(8) Main PID: 909 (nginx) Tasks: 2 (limit: 1152) CGroup: /system.slice/nginx.service ├─909 nginx: master process /usr/sbin/nginx -g daemon on; master\_process on; └─911 nginx: worker process Jan 30 11:29:15 ubuntu-s-1vcpu-1gb-blr1-01-monitoring systemd\[1\]: Starting A high performance web server and a reverse proxy server... Jan 30 11:29:16 ubuntu-s-1vcpu-1gb-blr1-01-monitoring systemd\[1\]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument Jan 30 11:29:16 ubuntu-s-1vcpu-1gb-blr1-01-monitoring systemd\[1\]: Started A high performance web server and a reverse proxy server. **Check if active** If you are using a monitoring service like [zabbix](https://medium.com/@gokulnk/understanding-zabbix-f2a83eeb1221) and need to check if a service is active you can use \# systemctl is-active nginx active ### Ready for Restart Inspite of all the precautions we take there will be scenarios where things fail. As debugging might take more time and can put your application or service out of action, we might be forced to restart our server. Making sure that everything works on a restart is hence very critical. List all loaded units systemctl `list-units -all` | grep loaded | awk '{print $1;}' List all enabled units systemctl `list-unit-files`| grep enabled | awk '{print $1;}' > enabled.txt Most of the times we need to make sure that all the services we use are in the start up script. List all loaded services systemctl `list-units -all` | grep service | grep loaded | awk '{print $1;}' List all enabled services systemctl `list-unit-files` | grep service | grep enabled | awk '{print $1;}' > enabled.txt To find the list of services which are loaded but not enabled we can do the following. systemctl `list-units -all` | grep service | grep loaded | awk '{print $1;}' > loaded.txt systemctl `list-unit-files` | grep service | grep enabled | awk '{print $1;}' > enabled.txt diff -y loaded.txt enabled.txt #If you want a quick glance of missing ones you can also use diff -y loaded.txt enabled.txt | grep '<' I know this is not fool proof but it can give you quick glance of missing services. ### Docker, Ansible et al Making sure that your server works as expected even after restarts lets you sleep with ease at night. We are considering moving our workflow to Docker and Ansible. That will take some time. Until then we will do with a general setup, hacks like these and a monitoring tool like [Zabbix](https://staging.app.learningpaths.io/#/highlights). Hope it helps you. If you liked this article and would like to read similar articles, don’t forget to clap.  Click and drag to clap more than once. 50 is the limit. You can read the others articles from the series. [**Understanding promises in JavaScript** _I have had a kind of “love and hate” relationship with JavaScript. But nevertheless JavaScript was always intriguing…_hackernoon.com](https://hackernoon.com/understanding-promises-in-javascript-13d99df067c1 "https://hackernoon.com/understanding-promises-in-javascript-13d99df067c1")[](https://hackernoon.com/understanding-promises-in-javascript-13d99df067c1) [**Understanding async-await in Javascript — Gokul N K — Medium** _Async and Await are extensions of promises. So if you are not clear about the basics of promises please get comfortable…_hackernoon.com](https://hackernoon.com/understanding-async-await-in-javascript-1d81bb079b2c "https://hackernoon.com/understanding-async-await-in-javascript-1d81bb079b2c")[](https://hackernoon.com/understanding-async-await-in-javascript-1d81bb079b2c) [**Should I use Promises or Async-Await** _I recently read a medium post where the author claimed that using async-await is better than using promises. While this…_hackernoon.com](https://hackernoon.com/should-i-use-promises-or-async-await-126ab5c98789 "https://hackernoon.com/should-i-use-promises-or-async-await-126ab5c98789")[](https://hackernoon.com/should-i-use-promises-or-async-await-126ab5c98789) If you are interested in cryptocurrencies checkout [**10 things to know/do before investing in cryptocurrencies** _“Never Invest In Something You Don’t Understand”_hackernoon.com](https://hackernoon.com/10-things-to-know-do-before-investing-in-cryptocurrencies-a6c72367d854 "https://hackernoon.com/10-things-to-know-do-before-investing-in-cryptocurrencies-a6c72367d854")[](https://hackernoon.com/10-things-to-know-do-before-investing-in-cryptocurrencies-a6c72367d854) [**Beginner’s Guide to “Investing in Cryptocurrencies”** _It has been more than an year since I started investing in cryptocurrencies. Following Warren Buffet’s advice of “Never…_hackernoon.com](https://hackernoon.com/beginners-guide-to-investing-in-cryptocurrencies-e2636d9c2fd9 "https://hackernoon.com/beginners-guide-to-investing-in-cryptocurrencies-e2636d9c2fd9")[](https://hackernoon.com/beginners-guide-to-investing-in-cryptocurrencies-e2636d9c2fd9) [**Why comparing cryptocurrency prices is wrong** _Price is an important indicator. But it can also be misleading in many cases._blog.goodaudience.com](https://blog.goodaudience.com/why-comparing-cryptocurrency-prices-is-wrong-2054a9075878 "https://blog.goodaudience.com/why-comparing-cryptocurrency-prices-is-wrong-2054a9075878")[](https://blog.goodaudience.com/why-comparing-cryptocurrency-prices-is-wrong-2054a9075878)