how to start cron jobs on Qnap?
-
- Know my way around
- Posts: 131
- Joined: Thu Oct 11, 2007 4:18 am
- Location: Holstebro, Denmark
how to start cron jobs on Qnap?
I would be ever so happy if anyone would let me in on the secret about cron jobs: How do you access crontab on a Qnap? I have the TS209 and serving (among other pages) an event calendar that should be mailed to participant at fixed times. I've found several how-to's on the net but how to access them?
Thanks!
L3kris
Thanks!
L3kris
TS-219
FW:3.3.0
FW:3.3.0
- AndyChuo
- Experience counts
- Posts: 2388
- Joined: Thu Sep 13, 2007 11:56 am
- Location: Taipei, Taiwan
Hi L3kris,
The 'crontab' is located in /mnt/HDA_ROOT/.config/crontab which can be edited using vi via ssh or telnet. After that, issue '/etc/init.d/crond.sh restart' to restart the cron service in order for the new jobs to take effect. Make sure you do understand what you are doing before you start to edit.
Andy
The 'crontab' is located in /mnt/HDA_ROOT/.config/crontab which can be edited using vi via ssh or telnet. After that, issue '/etc/init.d/crond.sh restart' to restart the cron service in order for the new jobs to take effect. Make sure you do understand what you are doing before you start to edit.
Andy
=============================================================>>>
TS-659-Pro [RAID6] rtorrent+SABnzbdplus+SickBeard+Couchpotato [Best PVR] Plex+PMS [Ultimate Streamer]
Apple iPad [Best Tablet] HTC One M8 [Mobile Phone] Samsung UA46ES6100 [My Screen] KRK Rokit 6 [Audio Speakers]
Chrome Cast [Screen Casting] Philips Hue [Personal Lighing]
Buffalo WZR-1750DHP [My Wifi Hub] D-Link DGS-1005D [Gbit Network]
=============================================================>>>
TS-659-Pro [RAID6] rtorrent+SABnzbdplus+SickBeard+Couchpotato [Best PVR] Plex+PMS [Ultimate Streamer]
Apple iPad [Best Tablet] HTC One M8 [Mobile Phone] Samsung UA46ES6100 [My Screen] KRK Rokit 6 [Audio Speakers]
Chrome Cast [Screen Casting] Philips Hue [Personal Lighing]
Buffalo WZR-1750DHP [My Wifi Hub] D-Link DGS-1005D [Gbit Network]
=============================================================>>>
-
- Know my way around
- Posts: 131
- Joined: Thu Oct 11, 2007 4:18 am
- Location: Holstebro, Denmark
Thank you - that works
Next I'd like to know how the command line should be written when I want to run a php script. I found a manual on the net instructing to include the php location. Is that correct?
Could you please make an example of, say, a php script "cron.php" placed in the root of Qweb to be run every day at 13H.
I know the first part: but what from there?
Thank you
Next I'd like to know how the command line should be written when I want to run a php script. I found a manual on the net instructing to include the php location. Is that correct?
Could you please make an example of, say, a php script "cron.php" placed in the root of Qweb to be run every day at 13H.
I know the first part:
Code: Select all
0 13 * * *
Thank you
TS-219
FW:3.3.0
FW:3.3.0
-
- Know my way around
- Posts: 131
- Joined: Thu Oct 11, 2007 4:18 am
- Location: Holstebro, Denmark
-
- New here
- Posts: 4
- Joined: Mon Oct 29, 2007 9:13 pm
run cron.php
the command to run cron.php is:
wget /yourpath/cron.php
so the line in crontab is:
0 13 * * * * wget /yourpath/cron.php
wget /yourpath/cron.php
so the line in crontab is:
0 13 * * * * wget /yourpath/cron.php
- adnovea
- Easy as a breeze
- Posts: 490
- Joined: Sat Jan 26, 2008 2:47 am
Re: how to start cron jobs on Qnap?
Because QNAP has a CRON capability and after having some troubles with WebCron.Org (missed randomly some tasks),
I've decided to write my own WebCron interface. Few lines of code for the Web Interface and WGET to call the web pages.
BUT ...
when using WGET with the CronTab GUEST account IT DOES NOT WORK !!!
Any other tasks (such as cp, echo, etc) works fine but WGET.
The tasks in the crontab is executed (I can check it because an empty log file is created) but nothing else occurs.
So I've been stuck so close to finish my application - it's puzzling.
Does someone have an idea why WGET is not working when run from the USER crontab ? (#crontab -e -u guest)
This code perfectly works when added into "crontab -e"
but does not work when added with "crontab -e -u guest" which is the account you can access from the Web (Qweb).
Thanks for your help
I've decided to write my own WebCron interface. Few lines of code for the Web Interface and WGET to call the web pages.
BUT ...
when using WGET with the CronTab GUEST account IT DOES NOT WORK !!!
Any other tasks (such as cp, echo, etc) works fine but WGET.
The tasks in the crontab is executed (I can check it because an empty log file is created) but nothing else occurs.
So I've been stuck so close to finish my application - it's puzzling.
Does someone have an idea why WGET is not working when run from the USER crontab ? (#crontab -e -u guest)
Code: Select all
* * * * * /usr/bin/wget --tries=3 --waitretry=30 --spider 'http://MYPAGE' -a /share/HDA_DATA/Qweb/cron.log
but does not work when added with "crontab -e -u guest" which is the account you can access from the Web (Qweb).
Thanks for your help
See my other projects at Sourceforge & Instructables
- pakoistinen
- Know my way around
- Posts: 149
- Joined: Sat May 24, 2008 12:38 pm
Re: how to start cron jobs on Qnap?
File system access rights and ownership settings? Did you check them?
I had some troubles with the guest account until I did some 'loosening up' with chmod and chown.
I had some troubles with the guest account until I did some 'loosening up' with chmod and chown.
TS-421 with QTS 4: 4 hdds: 2 x 1,5TB raid1 and 2 x 2TB raid1 arrays.
TS-209: 2 hdds: 2 x 750GB raid1 array.
Mail pasi at turvallisuus dot org
TS-209: 2 hdds: 2 x 750GB raid1 array.
Mail pasi at turvallisuus dot org
- adnovea
- Easy as a breeze
- Posts: 490
- Joined: Sat Jan 26, 2008 2:47 am
Re: how to start cron jobs on Qnap?
Thanks Pakoistinen for the advice but I didn't succeed (I'm not good with Linux anyway).
I've tried to chown and chmod the crontab guest file in /tmp/cron/crontabs but w/o success !
So I came back to the basic and wrote directly the command with "crontab -e" (admin account) and I have noticed :
- The command is executed because the log file is created
- BUT there is a problem with WGET
The command above works fine when directly typed into a console.
With the option -d set, the only line in the log file is :
--> DEBUG output created by Wget 1.10 on linux-gnueabi.
and no information about the connexion and so on.
When I reboot the server and manually launch the command above, I have to wait several hours before it works otherwise I get Segmentation fault
So the problem lies problably in WGET which has a strange behavoir rather than the crontab itself
I've tried to chown and chmod the crontab guest file in /tmp/cron/crontabs but w/o success !
So I came back to the basic and wrote directly the command with "crontab -e" (admin account) and I have noticed :
- The command is executed because the log file is created
- BUT there is a problem with WGET
Code: Select all
/usr/bin/wget --tries=3 --waitretry=30 --spider -d 'http://MYWEBSITE' -a /share/HDA_DATA/Qweb/webcron/log.txt
With the option -d set, the only line in the log file is :
--> DEBUG output created by Wget 1.10 on linux-gnueabi.
and no information about the connexion and so on.
When I reboot the server and manually launch the command above, I have to wait several hours before it works otherwise I get Segmentation fault
So the problem lies problably in WGET which has a strange behavoir rather than the crontab itself
See my other projects at Sourceforge & Instructables
-
- Know my way around
- Posts: 131
- Joined: Thu Oct 11, 2007 4:18 am
- Location: Holstebro, Denmark
Re: how to start cron jobs on Qnap?
I have now moved to a TS-219 - does anybody know where the crontab is located on this machine?
TS-219
FW:3.3.0
FW:3.3.0
- fribse
- Experience counts
- Posts: 2090
- Joined: Mon Feb 11, 2008 2:50 am
- Location: Greve, Denmark
- Contact:
Re: how to start cron jobs on Qnap?
My guess:
/etc/config/crontab
/etc/config/crontab
Best regards
Fribse
NO, RAID is NOT backup - Use RAID-Certified 24x7 drives for raid
HOWTO's:
Make automatic backup of ALL MySQL databases http://forum.qnap.com/viewtopic.php?f=32&t=15628
NAS-659 Pro II (3 GB Ram), Raid1, Survailance station, local backup destination + NAS-853A (16 GB Ram), Virtualization Station, Plex, iDrive
Network: Fritz!Box 7560 + 24p SG200 + 2x8p SG200 + 8p POE EdgeCore + 300/300 mbit Internet
Fribse
NO, RAID is NOT backup - Use RAID-Certified 24x7 drives for raid
HOWTO's:
Make automatic backup of ALL MySQL databases http://forum.qnap.com/viewtopic.php?f=32&t=15628
NAS-659 Pro II (3 GB Ram), Raid1, Survailance station, local backup destination + NAS-853A (16 GB Ram), Virtualization Station, Plex, iDrive
Network: Fritz!Box 7560 + 24p SG200 + 2x8p SG200 + 8p POE EdgeCore + 300/300 mbit Internet
-
- Know my way around
- Posts: 131
- Joined: Thu Oct 11, 2007 4:18 am
- Location: Holstebro, Denmark
-
- Starting out
- Posts: 35
- Joined: Thu Apr 28, 2011 7:15 pm
Re: how to start cron jobs on Qnap?
My tasks will not run with cronjob, so a have make a simple test file.
I have edit the crontab and add
* * * * * php /sbin/test.php
placed test.php in /sbin
test.php:
<?php
$myFile = "test.html";
$fh = fopen($myFile, 'a+') or die("can't open file");
$stringData = "<br>test/br>";
fwrite($fh, $stringData);
fclose($fh);
?>
restart cron
/etc/init.d/crond.sh restart
But no test.html not is found....
find / -name test.html
On my windowsmachine the php script is working.
So what's wrong?
I have edit the crontab and add
* * * * * php /sbin/test.php
placed test.php in /sbin
test.php:
<?php
$myFile = "test.html";
$fh = fopen($myFile, 'a+') or die("can't open file");
$stringData = "<br>test/br>";
fwrite($fh, $stringData);
fclose($fh);
?>
restart cron
/etc/init.d/crond.sh restart
But no test.html not is found....
find / -name test.html
On my windowsmachine the php script is working.
So what's wrong?
-
- Starting out
- Posts: 35
- Joined: Thu Apr 28, 2011 7:15 pm
Re: how to start cron jobs on Qnap?
I found ...
crontab /etc/config/crontab
/etc/init.d/crond.sh restart
crontab -l
http://wiki.qnap.com/wiki/Add_items_to_crontab
crontab /etc/config/crontab
/etc/init.d/crond.sh restart
crontab -l
http://wiki.qnap.com/wiki/Add_items_to_crontab