Hi all, I have a raspberry pi zero 2 w I'd like to use to record info about bluetooth devices that come within range of the pi.
I've setup this script based on post I found online about this.
writes data to /var/log/bluetooth_devices.log which seems to be ok... but I noticed it ends after about 20 seconds or so. I was thinking it would keep on running until ctrl+c
Is there a way to get this to auto run when my rpiz2w starts and for it to keep running ?
Thank you for your comments.
I was hopin
I've setup this script based on post I found online about this.
Code:
#!/bin/bashLOG_FILE="/var/log/bluetooth_devices.log"# Ensure the bluetooth controller is powered onbluetoothctl power onecho "Starting Bluetooth scan and logging to $LOG_FILE. Press Ctrl+C to stop."# Start scan in the background, prepend timestamps, and log to filestdbuf -oL bluetoothctl --timeout 30 scan on | ts '[%Y-%m-%d %H:%M:%S]' >> "$LOG_FILE" &# Capture the background process IDSCAN_PID=$!# Wait for a moment to let the scan startsleep 5# Optional: Keep the script running in an interactive session until manually stopped# You can remove this for automated cron jobswait $SCAN_PIDIs there a way to get this to auto run when my rpiz2w starts and for it to keep running ?
Thank you for your comments.
I was hopin
Statistics: Posted by remus — Wed Dec 10, 2025 12:28 pm