I had issue with BLE Connection which would drop after certain time which I solved using solution from this post:


The issue is that the values are automatically reset after next boot.So I have been trying to setup a script that would automatically configure the values on startup.

The script looks like:

echo 16 > /sys/kernel/debug/bluetooth/hci0/conn_min_interval
echo 17 > /sys/kernel/debug/bluetooth/hci0/conn_max_interval

Now I have tried setting up using Cron:

@reboot sudo sh /home/pi/bleConn.sh

I have also tried adding it to rc.local as per other posts but the script is not executed using either method. I have also configured for no-pass in visudo. I want this values to be configured only once at startup(script requires sudo permissions)

  • This looks more like a Linux question than a Raspberry Pi specific question. You might have better luck on the Unix and Linux exchange.
    – Fred
    Commented Oct 5, 2019 at 15:39

2 Answers 2


You can try to extend the bluetooth.service with the commands. Edit the service with:

rpi ~$ sudo systemctl edit bluetooth.service

In the empty editor insert these statements, save them and quit the editor:

ExecStartPre=/bin/bash -c 'echo 16 > /sys/kernel/debug/bluetooth/hci0/conn_min_interval; echo 17 > /sys/kernel/debug/bluetooth/hci0/conn_max_interval'

The service is executed with root rights by default so you don't have to worry about it.

  • Perfect!! This works as expected and settings are preserved after reboot.
    – Emrebel
    Commented Oct 7, 2019 at 6:22
  1. Make sure cron is enabled.

    systemctl status cron

    If it is not enabled, enable it.

    systemctl enable cron
  2. Execute it from the global crontab.

    Create a file /etc/cron.d/local or /etc/cron.d/ble. The name doesn't matter, just the directory /etc/cron.d. Add a line

    @reboot   root   sh /home/pi/bleConn.sh

    If you make /home/pi/bleConn.sh executable (and you should, with chmod a+x /home/pi/bleConn.sh), then you can omit the sh after root. This causes the command to be executed as root, so no need for sudo.

  3. Add logging to the script (second line):

    exec > /tmp/bleConn.log 2>&1
    echo 16 > /sys/kernel/debug/bluetooth/hci0/conn_min_interval
    echo 17 > /sys/kernel/debug/bluetooth/hci0/conn_max_interval

    If this creates the file /tmp/bleConn.log, then look at the content for the problem. If the file is not created, then you know that the script is not executed.

  4. Just a guess, maybe the script is executed before the modules are loaded the make the files available. You would see something like "/sys/kernel/debug/bluetooth/hci0/conn_min_interval does not exist". A simple fix is to wait long enough. Modify the cron line to sleep a few seconds, find a value that works for you.

    @reboot   root   sleep 30; /home/pi/bleConn.sh
  5. The proper way is to find the correct entries for the udev configuration. But it requires finding the correct file and may lead to problems after updates.

  • Thanks for the answer. While the selected answer has fixed the issue, I am thankful for detailed information regarding cron.
    – Emrebel
    Commented Oct 7, 2019 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.