Posted on

RTL-SDR Server as a service on Raspberry Pi

Now that Raspbian has changed to Systemd for managing auto-starting programs and daemons, I thought it was about time I moved away from using rc.local to start the rtl-sdr server.

If you ‘re currently using the rc.local file to start the server, begin by removing the server commands from that file.

The next job is to create a unit file to provide Systemd with the essential information for the management of the service. To create the unit file, use nano as follows.

Enter: sudo nano /etc/systemd/system/rtlsdr.service

Once nano opens, populate it with the following lines:

Description=RTL-SDR Server

ExecStart=/bin/sh -c ‘/usr/local/bin/rtl_tcp -a $(hostname -I)’


When you’ve entered the lines above, press ctl x then y and Enter to save the file.

To test the service, make sure the RTL dongle and network are connected and enter: sudo systemctl start rtlsdr.service. If that proceeds without error, you can check the status of the service with sudo systemctl status rtlsdr.service. If all is well, you should see a message showing that the RTL-SDR dongle has been found. You can stop the service with sudo systemd stop rtlsdr.service. If you’re happy that all is working ok, you can enable the service so it automatically starts at boot time. Enter the following: sudo systemctl enable rtlsdr. To disable the auto-start service it’s sudo systemctl disable rtlsdr.service

Time Saving Tip: When entering systemctl commands, you can omit the .service suffix.

You can find out more about Systemd at:

ExecStart Explanation

ExecStart=/bin/sh -c ‘/usr/local/bin/rtl_tcp -a $(hostname -I)’

This line starts the server but warrants some explanation. One of the problems with starting the rtl-sdr server as a service is the lack of a system variable to provide the Pi IP address. We need this because we have to pass the IP address to the server when it’s started. In this solution, I’ve called sh first and used the -c option. This tells sh to get the command line instruction from the quoted string that follows. That way we can use our standard call to rtl_tcp and combine it with the command line $(hostname -I) instruction to retrieve the IP address.


Mike – G4WNC





Leave a Reply

Your email address will not be published. Required fields are marked *