Earlier today, a tweet from a colleague got me wondering whether I could set up cron on my NAS drive to give me the ability to run scheduled tasks. I don't leave any machines on at home, but my NAS drive is on 24/7, so it could be useful - especially as a backup system if Google open an API to Takeout!
I managed to get it working with some help from this post, so I thought I blog the details here (it turned out to be simpler than that post suggested) should it be useful to you (or to me, should I ever need to do this again).
There was no requirement to do anything crazy to make this work. I didn't install anything on the NAS, everything was there - even the SSH access is enabled via the web app!
- Log in to the My Book admin web app.
- Go to the Advanced section.
- Tick to enable SSH access at the top of the page (note: you may need to update your firmware to get this option).
- SSH into to the IP address of your mybook, using the username "root" and the password displayed on the page where you enabled SSH access.
- Create a folder to store our crontabs. Since /var/spool is mapped to /tmp it'll be wiped at rebooted, so we need to keep our own.
- Create a job that touches /tmp/crontab.test every minute (for testing).
- Create an entry in init.d to start crond using our /etc/crontabs folder.
- Set permissions for execution.
That was all there was to it. I ran "reboot" and let the NAS reboot, then confirmed that /tmp/crontab.test was being touched every minute (with "ls /tmp/crontab.test -l").
Note: You should disable SSH access when you're done, or change the password. Otherwise, anybody on your network may be able to gain root access to your NAS!
If you make changes, you'll need to restart crond. You can do this with:
Next up, I'd like to find a way to edit the cron scripts from my chromebook via something like cloud9ide rather than ssh />Vi ;(