I have a small server, with Ubuntu OS, running 24/7, and with a script that is triggered only once a day to retrieve data from the net, and copy it to an external USB hard drive. This data copy is managed through a bash script. Roughly, the data copy starts at 00:00 and finishes at 5:00.
Because the external USB HDD is idle for a long period of time, I would like to start it only few minutes before data copy, and switch it off few minutes after data copy, directly through my bash script.
I had a look, and mostly identified 2 solutions, which I am not able to differentiate.
1. Using bind/unbind.
echo '1-2.2:1.0' > /sys/bus/usb/drivers/r8712u/bind # switch on
echo '1-2.2:1.0' > /sys/bus/usb/drivers/r8712u/unbind # switch off
2. Using autosuspend, from this SO question.
echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend_delay_ms"
echo "auto" > "/sys/bus/usb/devices/usbX/power/control"
Please, what is the difference, and which one would be the most appropriate for my use case?
Thanks a lot for your help. Have a good day, bests