Running as a Service
System Service
Example systemd service file (/etc/systemd/system/cic-daq.service):
[Unit]
Description=CIC Data Acquisition
After=network.target
[Service]
Type=simple
User=cic
WorkingDirectory=/opt/cic-daq
ExecStart=/opt/cic-daq/cic-daq --log /var/log/cic-daq
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Enable and start:
sudo systemctl enable cic-daq
sudo systemctl start cic-daq
User Mode Service
If you don't have root access, you can run as a user service. Create ~/.config/systemd/user/cic-daq.service:
[Unit]
Description=CIC Data Acquisition
After=network.target
[Service]
Type=simple
WorkingDirectory=%h/cic-daq
ExecStart=%h/cic-daq/cic-daq --log %h/cic-daq/logs
Restart=always
RestartSec=10
[Install]
WantedBy=default.target
Note: %h expands to your home directory.
Enable and start:
systemctl --user enable cic-daq
systemctl --user start cic-daq
To keep the service running after logout and start it automatically on boot, enable session lingering:
loginctl enable-linger $USER
Without lingering, user services only run while you are logged in.