cron - crontab to prevent USB hard drive from spinning down - Ask Ubuntu
i want prevent hard drive, internal drive externally attached via usb dock, spinning down. don't see way adjust apm through hdparm
, i'm assuming it's limited firmware of dock. spins drive:
sudo dd if=/dev/sdc of=/dev/null count=1 skip=$random
but when put same thing in crontab via
sudo crontab -e
and
* * * * * dd if=/dev/sdc of=/dev/null count=1 skip=$random
nothing happens. yes, did check whether drive @ /dev/sdc
. don't know if info relevant, i've edited crontab several times, , in each time, suggested save in different file default, followed. i'm not sure if correct usage of skip=$random
read random block prevent reading cache.
also, how can make sure target correct drive persistently across several boot-ups or other orders of plugging in other devices, rather targeting whatever ends being /dev/sdc
? i'm thinking like
dd if=(findmnt -rn -s uuid=number_from_blkid -o source) of/dev/null count=1 skip=$random
but don't know how nest return of parenthetical statement outer statement. , if could, return /dev/sdx2
, x
whatever letter happens , 2
usable partition. other windows reserved. less elegant plain sdx
.
the problems
- it runs using shell
/bin/sh
, not/bin/bash
,$random
doesn't work - unless set
path
withincrontab
file, won't know thingsdd
(or in solution below,bash
) located - if want using uuids, simpler way use
/dev/disk/by-uuid/the-uuid
the solution
find out device file under
/dev/disk/by-uuid
looking , checking don't errorsdd
(replacethe-uuid
actual uuid):ls -alf /dev/disk/by-uuid sudo dd if=/dev/disk/by-uuid/the-uuid of=/dev/null count=1 skip=$random
edit
root
'scrontab
(replacethe-uuid
actual uuid):* * * * * /bin/bash -c 'dd if=/dev/disk/by-uuid/the-uuid of=/dev/null count=1 skip=$random'
Comments
Post a Comment