I need to execute this script
cd /home/dietpi/prometheus && ./collectd_exporter --collectd.listen-address=":25827"
after the DietPI account is launched, and keep running in background, maybe there’s a way with DietPI-services or what’s the best way? I can also move in another folder the “collectd_exporter” script. I’m searching the best way to launch it (not at boot, /etc/rc.local don’t work, because it requires Prometheus server running) and keep it running.
Solved using crontab, I’m not sure if it’s the best way, but it works
@reboot cd /home/dietpi/prometheus && ./collectd_exporter --collectd.listen-address=":25827"
You could also use the
dietpi-autostart custom background option. But if it’s important that another service is started first, an own systemd service seems to be best, like so:
cat << '_EOF_' > /etc/systemd/system/prometheus-exporter.service
Description=Prometheus collectd exporter
systemctl enable --now prometheus-exporter