Is there a Bash script and/or daemon that I can write that will detect a specific USB drive and then sync that drive with a directory?
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- JQ: Select when attribute value exists in a bash a
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
I didn't do it myself, but you can try
udev
rules like this:Place it in
/etc/udev/rules.d/90-local.rules
or similar place, certainly dependable on your OS.For future reference, here's how to run a bash script upon detection of a USB drive.
Connect your device and run
lsusb
to retrieve the device's info. You should see something similar to this:In this case, the vendor ID of the device is 0bc2 and the product ID is 2100.
Now you can create your UDEV rule using a text editor of your choice.
And add this:
/home/myhome/my_script
is the path to your script which it would do whatever you want.To make sure the detection script will execute right away, run this command to reload the UDEV rules:
This was tested on Fedora 14.
Here is an example python deamon that you could use for the listening part, then copying the files to your directory shouldn't be a problem.