Run Goaccess as service use Systemd

Written on 21 June 2016

Goaccess Tutorial Series:
- Guide To Install and Use GoAccess Realtime web logs Analyzer.
- Use Goaccess Visual Web log analyzer on HTTP Web Browser(use Nginx)
- Run Goaccess as service use Systemd.

To use Goaccess in Web browser you can use this command

goaccess -f /var/log/nginx/example.com.access.log --real-time-html --ws-url=rp.example.com  --ignore-crawlers -o /var/www/goaccess/rp.html  

But to run rp.example.com as a solid service. We must run above command as a service.
1. Create a bash shell at /usr/local/bin/goaccessreport
And paste some text below

#!/bin/bash
goaccess -f /var/log/nginx/example.com.access.log --real-time-html --ws-url=rp.example.com  --ignore-crawlers -o /var/www/goaccess/rp.html  

Then grant execute permission to goaccesreport.

chmod +x goaccessreport  

Finally, Set up goaccess as a service use systemd
Make a service file at /etc/systemd/system/goaccessreport

[Unit]
Description=Goaccess Web log Report For Site Example.com  
After=network.target

[Service]
Type=simple  
User=root  
Group=root  
Restart=always  
ExecStart=/usr/local/bin/goaccessreport  
StandardOutput=null  
StandardError=null  
[Install]
WantedBy=multi-user.target  

Then enable and start this service

systemctl enable goaccessreport  
systemctl start goaccessreport  

Now go to rp.example.com to result.