[systemd-devel] Can't manage to start a task when bluetooth is ready with systemd

Gildas Bayard gildas.bayard at hds.utc.fr
Mon Aug 16 15:24:52 UTC 2021


Hello,

I've first posted on stackoverflow but couldn't get any usefull answer 
(gomenasai 😅)

I'm trying to start a task when bluetooth is ready on a raspi (running 
raspbian 10 - buster) with systemd. I've added the file 
/etc/systemd/system/my.service with this content

    |[Unit] After=bluetooth.target Requires=bluetooth.target [Service]
    Type=idle ExecStart=/root/my.sh [Install] WantedBy=multi-user.target |

Then I used the sudo systemctl enable my.service command, and rebooted.

After reboot I look at services launch order with |systemd-analyse 
plot|, and it turns out that my service starts after bluetooth.target as 
expected. But bluetooth.target gets started very early (attachment 
bt1.svg). And |systemctl show bluetooth.target| tells me 
'After=bluetooth.service' so why is bluetooth.target point is reached 
way before bluetooth.service?

I precise that if I use

    |[Unit] After=bluetooth.service Requires=bluetooth.service|

it's also weird: my service is started early, way before 
bluetooth.service and bluetooth.target (which as expected is activated 
rigth after bluetoothd is ready, attachment bt2.svg).

Could you tell me what's wrong?

Sincerely
||

-- 
*Gildas Bayard*
Ingénieur de Recherche
Responsable Sécurité des Systèmes d'Informations
Coordonnateur pour la Protection du Potentiel Scientifique et Technique
/Télétravail le mercredi/
Laboratoire HEUDIASYC - UMR CNRS 7253
UTC Centre de Recherches de Royallieu
BP 20529 - 60205 Compiègne Cedex
Tél. 03 44 23 46 71
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210816/b9fcb034/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bt2.svg
Type: image/svg+xml
Size: 76954 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210816/b9fcb034/attachment-0002.svg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bt1.svg
Type: image/svg+xml
Size: 77129 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210816/b9fcb034/attachment-0003.svg>


More information about the systemd-devel mailing list