1

I want a bash script to monitor USB ports of a linux server to detect when an external hard drive is plugged in and removed.

When a USB external drive is plugged in or removed, a text file is generated in some temp file about usb drive specs and time.

1 Answer 1

2

You probably already have udev running on your system, and it is monitoring connect/disconnect events. With the proper configuration it can trigger scripts to run, but it is primarily designed to create the device nodes.

On a Debian/Ubuntu system take a look at the existing rules in /lib/udev/rules.d, and /etc/udev/rules.d`. See the Run section of the udev man page, for details about executing a task.

See:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .