I want to execute my script when adding / removing of hardware is detected.
Now I use a loop and sleep every 10 sec, to recheck a new hardware, but I thought it would be better if I could put my script to system path that will run every time that hardware changes are detected, similar to “run every log in” when put script path to /etc/rc.local.
Write a udev rule that executes the script each time the appropriate hardware is added or removed.