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

How can I create a cron job that runs every minute and logs how much data was transferred by USB?

Ideally I want log of amount the data in bytes transfers done.

For example if i tranferred 4mb file from my pendrive to my computer system , and then 1 gb file from my computer system to pendrive ,it should log all this .

share|improve this question
What exactly would you like to log? Meta-data of files that have been created/deleted? The contents of files? An estimate of transferred bytes for files and metadata? Do you really want to log data, or are you trying to find out what files enter/leave your computer? – Lekensteyn Apr 13 '14 at 20:11
cron does not feels like it is the correct method to me. – Rinzwind Apr 13 '14 at 20:16
I was creating log analyser of USB devices , so i had to log as much information as available , I stuck on the amount of data in bytes transferred . – user3529205 Apr 14 '14 at 4:08
up vote 0 down vote accepted

I do not believe cron itself is the correct method but Wireshark has native support for doing a capture on the USB interfaces. From the link:


To dump USB traffic on Linux, you need the usbmon module, which has existed since Linux 2.6.11. Information on that module is available in /usr/src/linux/Documentation/usb/usbmon.txt in the Linux source tree. Depending on the distribution you're using, and the version of that distribution, that module might be built into the kernel, or might be a loadable module; if it's a loadable module, depending on the distribution you're using, and the version of that distribtuion, it might or might not be loaded for you. If it's a loadable module, and not loaded, you will have to load it with the command

modprobe usbmon

which must be run as root.

share|improve this answer
Where does information of capture goes , in which folder ? – user3529205 Apr 14 '14 at 4:38
the default is /var/log/ – Rinzwind Apr 14 '14 at 6:39

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.