Guide : Cron and opendns


This mod will allow you to run cron jobs or scripts at specified times within your mycloud.

Warning : Do these modifications will void the warrenty of your device.

This example of cron is used to update my router ip address with open dns and its **bleep** of DNS addresses for a dynamically assigned router ip address.

To do these changes requires SSH access, so first step is login via ssh.

Then create the script you want executed, I placed my script in /root

cd /root

cat update_opendns

wget -q -O - --user '' --password 'password' ''

 replace '’ with your opendns email address, and ’ password’ with your opendns login password. And you change Home into your ip filter label defined in opendns.

So once you have your script sorted, we start with cron entries.


cd /etc/cron.d
ls -al
total 52
drwxr-xr-x 2 root root 4096 Jul 26 22:34 .
drwxr-xr-x 76 root root 4096 Jul 28 18:45 …
-rw-r–r-- 1 root root 102 Jul 4 2012 .placeholder
-rwxr-xr-x 1 root root 130 May 21 2012 20-checkRAID
-rwxr-xr-x 1 root root 0 Jul 10 15:58 WDSAFE
-rwxr-xr-x 1 root root 121 Apr 16 13:25 auto_update
-rw-r–r-- 1 root root 72 Jan 4 2013 clean_alerts
-rwxr-xr-- 1 root root 445 Jul 26 22:34 my_cronjobs
-rw-r–r-- 1 root root 589 Aug 26 2012 mdadm
-rwxr-xr-x 1 root root 524 Apr 11 2012 php5
-rwxr-xr-x 1 root root 510 Jan 31 2013 php5.dpkg-dist
-rw-r–r-- 1 root root 82 Sep 25 2013 rescan_internal_volumes
-rw-r–r-- 1 root root 396 May 21 2012 sysstat
-rwxr-xr-x 1 root root 408 May 10 2012 system_monitor

You usually edit cron with the local user login (crontab -e), but this isn’t working in mycloud, so we will create our own cron tab in /etc/cron.d  and viewing the above list of files shows all the scheduled jobs that are run within your device. 

So start by creating the following file using your preferred editor, vi or nano.

cd /etc/cron.d

vi my_cronjobs


nano my_cronjobs

# Unlike any other crontab you don’t have to run the `crontab’
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

# m h dom mon dow user command
#* * * * * root date > /root/cron_stamp

##### Update Open DNS every 10 minutes if my cloud is not standby mode #####
*/10 * * * * root [! -f /tmp/standby] && /root/update_opendns

Save the changes and there you go …

This to note:

Notice that aditional parameter, root ; this is the user that will run the script.

Also notice the  ** [! -f /tmp/standby]** this means, if the /tmp/standby does not exist, then

run your  ** /root/update_opendns** script. So, basically, only run the script if the mycloud isn’t in standby or sleep mode.

m: minute or * means any minute, or */10 means every 10 mintues, or 0-59.

h : hour in 24 hour mode, or * for any hour, or 0-23.

dom: 1-31 days of the month, or * for any hour.

mon: 1-12 for months, or * for any month.

dow: 0-7 or * for any week day.

If you want to output to a log file, notice the output from df -h

df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 1.9G 615M 1.2G 34% /
/dev/root 1.9G 615M 1.2G 34% /
tmpfs 23M 2.6M 20M 12% /run
tmpfs 40M 4.0K 40M 1% /run/lock
tmpfs 10M 0 10M 0% /dev
tmpfs 5.0M 0 5.0M 0% /run/shm
tmpfs 100M 284K 100M 1% /tmp
/dev/root 1.9G 615M 1.2G 34% /var/log.hdd
ramlog-tmpfs 20M 2.2M 18M 11% /var/log
/dev/sda4 3.6T 1.7T 1.9T 49% /DataVolume
/dev/sda4 3.6T 1.7T 1.9T 49% /CacheVolume
/dev/sda4 3.6T 1.7T 1.9T 49% /shares
/dev/sda4 3.6T 1.7T 1.9T 49% /nfs/MediaServer
/dev/sda4 3.6T 1.7T 1.9T 49% /nfs/SmartWare
/dev/sda4 3.6T 1.7T 1.9T 49% /nfs/scripts
/dev/sda4 3.6T 1.7T 1.9T 49% /nfs/Public
/dev/sdb1 1.9T 1.3T 582G 69% /var/media/1_8TB_EXT
/dev/sdb1 1.9T 1.3T 582G 69% /nfs/1_8TB_EXT

The filesystems with tmpfs are essentially ram drives. This means when you restart the mycloud these files will disappers. It also means they exist in the mycloud physical ram which will allow for fast access, and more importantly, they will not cause an I/O to your mycloud phyiscal drive allowing it to go into standby mode. However, do not get carried away with large log files in these filesystems. They will consume more and more ram from your mycloud and cause a performance hit. The O/S will then start to page memory into the disk and you will lose the benefit gained from the ram drive.

So for example, to change the update_opendns   such that it outputs to a log file

cd /root

cat update_opendns

wget -q -O - --user '' --password 'yourpassword' '' | xargs -0 printf "$(date) :: ->%s<-\n" 2>&1 > /tmp/opendns_update.log

The above change basically takes output from wget and pipes it into xargs which then call the printf program to add date/time info and the pass the out from wget into printf as parameter, then redirect any errors to the stdout and then redirect the whole output to a file /tmp/opendns_update.log.


Thanks for sharing this guide for those interested. As a reminder to all Users, this is done at your own personal risk.



In the My Passport Wireless drive, all the files in /etc/cron.d are assembled into the actual crontab in /var/spool/cron/root by the cron startup script in /etc/init.d.

So after you make your modification in /etc/cron.d, go ahead and run this:

# ls /etc/init.d/*cron*

# /etc/init.d/S99crond restart
Shutting down crond services: done
Starting crond services: done

 If you look at /etc/init.d/S99crond (or whatever it’s called in your system), you will see what it’s doing.

Of course, alternatively, you can just restart your device.

Best regards,