The best thing about these devices though it that they run Linux OS utilising Debian Essential and as such they can be configured to do almost anything you want. Out of the box they already come with file serving, media serving, database and web servers.
One slight problem though is that the boot up process is not disimilar to that of a live CD. This is great in that it makes the system highly robust and it boots to a known state each time. The problem is that short of rewriting the firmware you can't introduce things into the boot process. What I don't want to do is have to re-run a load of scripts to configure the server how I want it after a power failure or forced reboot.
The boys over on the QNAP forums are really on the case and one of the chaps has created a nice little framework script which hooks into the boot process and allows the execution of a series of scripts. You can see his work here.
After installing this workaround you can add scripts to the scripts folder and take control of your server.
One of the things I wanted to do was add items to my cron list and this process is explained below.
1. SSH into your QNAP box
2. Install the custom scripts files at http://www.qnap.box.cx/ as per the directions there.
3. CD to your scripts directory in custom and make a file called joblist.txt in VI (Vi is the only editor you have on the QNAP drive).
# vi joblist.txtWhen in vi make your list of cron jobs using the standard CRON syntax.
Mine was the following:
25 1 * * * /share/backup/script.shThis will run a backup script I had written at 1:25am everyday. You can add as many or as few as you want. Save your document and exit from Vi.
4. Make your script that will fire on start up. I called mine cron_update.sh
# vi cron_update.shIn there put the following code:
#!/bin/sh
# this script apprends a job list to the existing crontab
echo "Reconfigure CRON list:"
cronpath=/share/MD0_DATA/custom/scripts
#list the cron tab and put in a temp file
crontab -l > $cronpath/cron_jobs.txt
#append the items we want to the master cron jobs list
cat $cronpath/joblist.txt >> $cronpath/cron_jobs.txt
# replace the existing crontab with the new one
crontab $cronpath/cron_jobs.txtSave and quite out of Vi.
You'll notice I've used a variable in here to specify where to find the files. This is because the autorunmaster script is a folder higher so we need to be explicit about where to find things.
5. Go back up a directory to your custom folder. In there edit your autorunmaster.sh file with vi.
# vi autorunmaster.shAt the end of the file append:
/share/MD0_data/custom/scripts/cron_update.shThen save and close the file.
Now when you reboot you should have your newly added cron jobs appended to the crontab without removing all the old ones.


11 comments:
Hi Andrew,
thanks for the script. I use it with a QNAP TS 109 pro II to start the backup-job. But I have to replace the 'MD0_Data' for a 'HDA_DATA' on this system.
Greetings from Germany
Gerd Bender
Hi Andrew,
Do you know of any instructions out there describing how to manage torrent downloads from the QNAP Linux command line instead of the "Download Station" web interface?
Thanks,
P
Hi guys,
I got a ts-209 pro II and the easiest way to add new cron jobs is to update the file /etc/config/crontab and rerun crontab /etc/config/crontab to update running jobs.
Cheers!
Dadje
This is great info to know.
Hi,
great thing.
But I noticed one problem with the cron_update script.
My autorun.sh is executed also the update script but the last operation (installing the new cron tab from the file) does not work directly after boot up.
When I start it by hand after the boot up everything is working fine...
any idea??
QNAP TS-204 II Pro
To Supermans:
Have the same prob - hope someone has an idea!!!!
Please help us ...
Hey folks, I had the same problem. It seems to be a timing issue. Since I could not figure the root cause I simply send my script called by the autorunmaster.sh in the background. Then my script goes to sleep for 5 minutes and add the script to crontab. That worked fine. cheers frank
I have also seen that the crontab changes when some configuration is changed. Then the crantab gets overwritten.
Has anyone seen the same thing happening?
/Jacob
Really appreciated - added to favourites!
Thank you :)
Hello !.
You may , probably very interested to know how one can collect a huge starting capital .
There is no initial capital needed You may start to get income with as small sum of money as 20-100 dollars.
AimTrust is what you thought of all the time
AimTrust incorporates an offshore structure with advanced asset management technologies in production and delivery of pipes for oil and gas.
It is based in Panama with offices everywhere: In USA, Canada, Cyprus.
Do you want to become really rich in short time?
That`s your choice That`s what you wish in the long run!
I feel good, I began to get real money with the help of this company,
and I invite you to do the same. If it gets down to choose a correct companion who uses your money in a right way - that`s the AimTrust!.
I take now up to 2G every day, and my first deposit was 1 grand only!
It`s easy to join , just click this link http://igulodydus.dreamstation.com/zocily.html
and lucky you`re! Let`s take this option together to feel the smell of real money
Hello !.
You may , probably very interested to know how one can collect a huge starting capital .
There is no need to invest much at first. You may start earning with as small sum of money as 20-100 dollars.
AimTrust is what you haven`t ever dreamt of such a chance to become rich
The firm represents an offshore structure with advanced asset management technologies in production and delivery of pipes for oil and gas.
Its head office is in Panama with structures everywhere: In USA, Canada, Cyprus.
Do you want to become an affluent person?
That`s your choice That`s what you wish in the long run!
I`m happy and lucky, I began to take up real money with the help of this company,
and I invite you to do the same. If it gets down to choose a correct companion utilizes your money in a right way - that`s the AimTrust!.
I earn US$2,000 per day, and what I started with was a funny sum of 500 bucks!
It`s easy to start , just click this link http://toderavah.kogaryu.com/vucode.html
and lucky you`re! Let`s take this option together to become rich
Post a Comment