linux - Bash script to detect when my USB is plugged in and to then sync it with a Directory -
is there bash script and/or daemon can write detect specific usb drive , sync drive directory?
for future reference, here's how run bash script upon detection of usb drive.
connect device , run lsusb
retrieve device's info. should see similar this:
$ lsusb bus 002 device 039: id 0bc2:2100 seagate rss llc
in case, vendor id of device 0bc2 , product id 2100.
now can create udev rule using text editor of choice.
$sudo vi /etc/udev/rules.d/85-my_usb_device_rule.rules
and add this:
action=="add", subsystem=="usb", sysfs{idvendor}=="0bc2", sysfs{idproduct}=="2100", run+="/home/myhome/my_script"
/home/myhome/my_script
path script whatever want.
to make sure detection script execute right away, run command reload udev rules:
$sudo udevadm control --reload-rules
this tested on fedora 14.
Comments
Post a Comment