Skip to main content

Thread: Need Help running cron as root


i have external usb hard drive spins down every 10 min. commands in 'hdparm' nothing override internal settings. so, wrote script touch file every 5 minutes, , run root because of mount command, , want run every user. script executable, owned root, , root group, 755 permissions.

no_sleep.sh in /usr/sbin:
code:
#!/bin/bash  # script keep external drive spinning down    diskmounted=$(mount | grep backup | wc -c)    if [ $diskmounted -gt 0 ]      touch /mnt/backup/.nosleep  fi
in terminal, i've editted crontab root by:
code:
sudo crontab -e -u root
this looks like:
code:
#keep external hd spinning down touching file every 5 min  */5 * * * * root /usr/sbin/no_sleep.sh > ~/desktop/no_sleep_test.txt
i'm not getting hidden file .nosleep in /mnt/backup, or output desktop asked. doing wrong?

you don't need -u option, since sudo implies "root":
code:
sudo crontab -e
try (replace "your_username"):
code:
*/5 * * * * /usr/sbin/no_sleep.sh >/home/your_username/desktop/no_sleep_test.txt 2>&1
also, "sdparm" command might let change drive's settings. may need install it.


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help Need Help running cron as root


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support