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

  1. it runs using shell /bin/sh, not /bin/bash, $random doesn't work
  2. unless set path within crontab file, won't know things dd (or in solution below, bash) located
  3. if want using uuids, simpler way use /dev/disk/by-uuid/the-uuid

the solution

  1. find out device file under /dev/disk/by-uuid looking , checking don't errors dd (replace the-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 
  2. edit root's crontab (replace the-uuid actual uuid):

    * * * * * /bin/bash -c 'dd if=/dev/disk/by-uuid/the-uuid of=/dev/null count=1 skip=$random' 

Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User