Running a shell script on device mount


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running a shell script on device mount
# 1  
Old 12-02-2009
Running a shell script on device mount

Something I have always wondered but never had any luck finding information on is running a shell script when a device mounts...

Lets say I have an external hard drive as a back up, every time I plug the device in I want to launch a shell script to rsync a few directories.

How would I do this other then polling the mount points?

Thanks

Last edited by d3mcfadden; 12-02-2009 at 04:31 PM..
# 2  
Old 12-02-2009
What OS ?
# 3  
Old 12-02-2009
On recent Linux, you can have a script run when the device is detected. (not when it mounts, but when it is detected) by crafting a udev rule for that device.
# 4  
Old 12-02-2009
udev rule... i will check this out. FreeBSD.
# 5  
Old 12-02-2009
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Android Device ID Changer shell script

this is worked "ANDROID NOUGAT" how can i use it for "ANDROID OREO" -plz help me... ------------------------------------------- echo " Ã-~-DEVICE ID CHANGINGÃ-~-" sleep 2 echo " " COUNT=1 while do ; echo "settings put secure android_id " | tr -d '\n' > X1... (4 Replies)
Discussion started by: f4is4l
4 Replies

2. Solaris

How to map device to mount point?

Solaris 11, iostat -xncz 5 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device 6.0 18.2 226.7 205.6 0.0 0.0 0.0 1.7 0 3 vdc206 6.8 39.6 252.6 341.0 0.0 0.1 0.0 1.5 0 4 vdc207 ... (9 Replies)
Discussion started by: Sean
9 Replies

3. UNIX for Beginners Questions & Answers

Mount : Device busy

mount -f nfs 1234:/export/ert /der/fr/ert mount : /der/fr/ert: device busy normally I will then do an fuser filesystem and kill the pids, which I did. now if I do an fuser /der/fr/ert I get the mount point and no pid > fuser /der/fr/ert /der/fr/ert: but it... (1 Reply)
Discussion started by: goya
1 Replies

4. Debian

Device error 71, won't mount root filesystem

I have a Debian OpenBox that boots from any usb port. The Debian LXDE will only boot from one specific port. It needs to look at all of them to find and be root, and mount the root filesystem by UUID. Both are full installs to 16GB flash drives. That is not being done. It says during boot... (0 Replies)
Discussion started by: patrick013
0 Replies

5. Solaris

zones: Use a zpool or mount as a raw device?

Hi, I need to create 4 zones. I have an array with a RAID5 volume. I have exported 4 LUNS from the array. Now my host see the 4 LUNS as raw devices. I am partitioning each LUN using format then mounting each slice on the global zone. Then I am using each slice as a file system for my non... (3 Replies)
Discussion started by: general_lee
3 Replies

6. Shell Programming and Scripting

Shell script to make and mount a Partition

Hi, I need to mount a new partition in a series of Pc that have a single hard drive of 20 GB; the used and partioned space amounts to 10 GB, between root, boot and swap; the script is to make the mounting process automatic These are the contents of my script: ... (1 Reply)
Discussion started by: HernandJ2
1 Replies

7. Shell Programming and Scripting

Shell Script to see the mount points.

Hi all, First of all I dont even know the ABC of scripting .. But now I want a Script to see the mount points of the file systems Can any body help plsssssssss :o (1 Reply)
Discussion started by: priky
1 Replies

8. Solaris

Running from Shell Vs running from RC script

Hi, i have a script which need to do behave differently when run as a startup process from init.d/ rc2.d script and when run manually from shell. How do i distinguish whether my script is run by init process or by shell?? Will the command /proc/$$/psinfo | grep "myscript" work well???... (2 Replies)
Discussion started by: vickylife
2 Replies

9. Shell Programming and Scripting

shell script to mount filesystem

Hi, Gurus: I need your help to finish a script that will mount two file systems automatically when saver is reboot or start. I am working on a new Sun Sparc machine with Solaris 9 on it. This box got two disk. disk one has been partitioned to hold Solaris OS. disk two has been partitioned as... (6 Replies)
Discussion started by: duke0001
6 Replies

10. Solaris

mount: /dev/dsk/c0t6d0s0 no such device

I've searched through unix.com and google for this issue I am having on one particular Sun E280R with installing netbackup software from CD. I know the cd is good because i installed the software on 4 other servers right before this one. This is the issue I am seeing. vold does not mount the CD... (2 Replies)
Discussion started by: dangral
2 Replies
Login or Register to Ask a Question