Find the answer to your Linux question:
Results 1 to 3 of 3
I've been googling a couple of days for this, but still haven't found a clear way to run my script once the media is inserted/detected/mounted. I'm running a small Linux ...
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    4

    How to run a script on media insert??

    I've been googling a couple of days for this, but still haven't found a clear way to run my script once the media is inserted/detected/mounted.

    I'm running a small Linux server with SUSE 10.1, the PC (HP Media Center) has a bay for USB hard drive. This drive is used for backup purposes.

    So ideally I want to start the backup when the drive is inserted into the bay.
    I didn't find how to do this so far. I've been thinking of stupid CRON script that will check every 10 mins if drive is mounted and if it is - start the backup, but I hope there is some more natural way to do this... Something like if-up / if-down scripts for network interfaces.

    Then the drive is inserted it get's automatically mounted on /media/$PRODUCT, I'm not sure this is automount feature, since I haven't configured it, it more looks a kernel/module feature. For the moment I've just reformated the drive into Reiser FS and changed mount point to /media/backup.

    Anyone has any ideas?

  2. #2
    Linux Engineer Zelmo's Avatar
    Join Date
    Jan 2006
    Location
    Riverton, UT, USA
    Posts
    1,001
    You can supposedly do it with a udev rule. I haven't used this particular feature of udev so I can't vouch for its fitness, but modifying udev rules is pretty straightforward and is explained quite thoroughly in the above link.
    Stand up and be counted as a Linux user!

  3. #3
    Just Joined!
    Join Date
    Mar 2007
    Posts
    4
    Thanks for prompt answer!

    At first glance it looks it that is what i'm looking for. Will try to configure udev on my system and see if it works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...