I think I'm having part terminology problem, part just plain newb problem, part tired of reading problem.
I've gotten so far on my home energy monitor project, from getting my SDR radio working, decoding the data, pushing json to InfluxDB, running Grafana and getting graphs! All through googling as I have less than 2 months Linux experience (just playing with Raspberry Pi/OrangePi.
My OrangePi runs Armbian Ubuntu 16.04
I need a very simple "command" to execute at boot. It will be running all the time in the background. So I guess that makes it a daemon? The command is
/home/jonboy545/GoCode/bin/rtlamr -filterid=62059972 -format=json -msgtype=idm unique=true | rtlamr-collect
That's it. I made a simple script called log_energy.sh, made it executable. It's just:
#!/bin/bashr
/home/jonboy545/GoCode/bin/rtlamr -filterid=62059972 -format=json -msgtype=idm unique=true | rtlamr-collect;
If I type ./log_energy.sh into a terminal window, everything works great. I have to open a SCREEN instance, so I can detach it so I don't have to leave the terminal open. Obviously this isn't the best solution.
So, do I put this into rc.local? I had some issues, I think it's executing too soon, so I tried putting a sleep 60 in there but it still was sporadic. Sometimes it worked, sometimes it didn't. So I thought about using crontab and just have it execute @reboot. Again, probably not the best solution. Also there are environment variables that must be declared and are set in ~/.profile (I guess they could go anywhere) and I'm not sure that crontab "reads" those environment variables, atleast that's what I've read.
So what's the "proper" way to have this script execute at boot (maybe at the very end, once everything has "settled down."
Ultimately I'd like to have it as a "service" called "energylog" so I could do a sudo service energylog start/stop/restart.
I've looked at /etc/init.d/skeleton as well as some already existing files in /etc/init.d but I'm not really sure what I'm looking at.
Can somebody steer me in the right direction?
Many thanks!