I want to execute rsync command which syncs my local directory with the external ssd. I followed the instructions given in this link. to execute some command based on udev rules. This shows how to run the command for specific usb drive based on idVendor and idProduct. Here is the command I have in my /etc/udev/rules.d/test.rules:
ATTRS{idVendor}=="0781", ATTRS{idProduct}=="558c", RUN+="/temp/auto_back.sh"
and in /tmp/auto_back.sh
I just have
#!/bin/bash
# auto backup command
rsync -avzh /home/abhishek/Dropbox /media/abhishek/Hachiko
I don't have much insight about this. I just thought it might work. But it doesn't. I read that sometimes the command gets executed before the drive is even mounted. Can you give me some insight on what I am doing wrong, and how this thing works? Also, is there any way to make the command in script to wait for some time before it executes?