Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to automatically copy images off a camera when it is inserted into the USB port. I've written a script to do the copying, and I've found that, by creating a file


with the line

ACTION=="add", KERNEL=="sdg1", RUN+="/path/to/my/script"

I can invoke the script when a USB device (such as the camera) is inserted.

The script is invoked at a time when the disk hasn't been mounted yet. My workaround is to make the script start the copying process in the background after some sleep to give it time for the file system to be mounted, but it would be better to trigger the script right after the file system has been mounted.


share|improve this question

The following may work:

Run dbus-monitor before you mount the USB and see what events it generates when the USB is mounted.

Then do something like this How do I run a script on a dbus signal?

share|improve this answer
I'll let you know when I have time to try this out ... – Reinier Post Feb 21 '14 at 9:24
This is more what he was looking for...… – RobotHumans Sep 27 '14 at 7:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.