I have the same issue, and none of the suggestions provided across the forum are working (add delay, background process, wrap daemon in shell script and so on).
For example:
echo "Before" > /tmp/before
/usr/bin/snmp_exporter.sh &
echo "After" > /tmp/after
exit 0
The 'Before' and 'After' both run, and create their respective files in /tmp/, but the shell script in the middle, does not. That shell script is a simple:
#!/bin/sh
sleep 30
/usr/bin/snmp_exporter --config.file=/etc/snmp/snmp.yml 2>&1
When SSH'ing in, running the same shell script works as expected. Ownership, permissions, bits are all correct.
Putting the raw command itself, into the "Custom Scripts" section, also does not run, which is why I tried wrapping it into a shell script.
The added 'sleep' is there based on a recommendation on another similar thread, where they couldn't get it working either. The sleep didn't help here, and doesn't add any value.
I also tried this form of invocation (again, this works from the shell, does not work in "Custom Scripts")
sh -c /usr/bin/snmp_exporter.sh &
Has anyone figured out why Custom Scripts aren't being run at all?
UPDATE: It turns out I needed a little more magic in the rc.local script to get it working. This now works:
exec 2> /tmp/rc.local.log
exec 1>&2
set -x
/usr/bin/snmp_exporter --config.file=/etc/snmp/snmp.yml 2>&1 &
exit 0