how to start cron jobs on Qnap?

Post your questions about Web Server usage and Apache + PHP + MySQL/SQLite web applications.
L3kris
Know my way around
Posts: 131
Joined: Thu Oct 11, 2007 4:18 am
Location: Holstebro, Denmark

how to start cron jobs on Qnap?

Post by L3kris »

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
TS-219
FW:3.3.0
User avatar
AndyChuo
Experience counts
Posts: 2388
Joined: Thu Sep 13, 2007 11:56 am
Location: Taipei, Taiwan

Post by AndyChuo »

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. :D

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]
=============================================================>>>
L3kris
Know my way around
Posts: 131
Joined: Thu Oct 11, 2007 4:18 am
Location: Holstebro, Denmark

Post by L3kris »

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:

Code: Select all

0 13 * * *
but what from there?
Thank you
TS-219
FW:3.3.0
L3kris
Know my way around
Posts: 131
Joined: Thu Oct 11, 2007 4:18 am
Location: Holstebro, Denmark

Bump

Post by L3kris »

Does nobody know how to make a cron command line that refers to a php script? :shock:
TS-219
FW:3.3.0
Goggy
Starting out
Posts: 12
Joined: Sun Sep 16, 2007 1:10 am

Post by Goggy »

Hmm - dont think you are really knowing what you are doing :wink:
L3kris
Know my way around
Posts: 131
Joined: Thu Oct 11, 2007 4:18 am
Location: Holstebro, Denmark

Post by L3kris »

Maybe not :lol: but at least it's nice to be told so...

What I need is a script that sends emails twice a week at predefined times. As far as I know that's one of the things cron jobs are for, right? So please enlighten me on how to do it :?: if somebody can do that...
TS-219
FW:3.3.0
cgalli
New here
Posts: 4
Joined: Mon Oct 29, 2007 9:13 pm

run cron.php

Post by cgalli »

the command to run cron.php is:

wget /yourpath/cron.php

so the line in crontab is:

0 13 * * * * wget /yourpath/cron.php
User avatar
adnovea
Easy as a breeze
Posts: 490
Joined: Sat Jan 26, 2008 2:47 am

Re: how to start cron jobs on Qnap?

Post by adnovea »

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)

Code: Select all

* * * * * /usr/bin/wget --tries=3 --waitretry=30 --spider 'http://MYPAGE' -a /share/HDA_DATA/Qweb/cron.log
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
See my other projects at Sourceforge & Instructables
User avatar
pakoistinen
Know my way around
Posts: 149
Joined: Sat May 24, 2008 12:38 pm

Re: how to start cron jobs on Qnap?

Post by pakoistinen »

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.
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
User avatar
adnovea
Easy as a breeze
Posts: 490
Joined: Sat Jan 26, 2008 2:47 am

Re: how to start cron jobs on Qnap?

Post by adnovea »

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

Code: Select all

/usr/bin/wget --tries=3 --waitretry=30 --spider -d 'http://MYWEBSITE' -a /share/HDA_DATA/Qweb/webcron/log.txt
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 :?
See my other projects at Sourceforge & Instructables
L3kris
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?

Post by L3kris »

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
User avatar
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?

Post by fribse »

My guess:
/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
L3kris
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?

Post by L3kris »

Thanks :-)
TS-219
FW:3.3.0
Dennisonline
Starting out
Posts: 35
Joined: Thu Apr 28, 2011 7:15 pm

Re: how to start cron jobs on Qnap?

Post by Dennisonline »

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?
Dennisonline
Starting out
Posts: 35
Joined: Thu Apr 28, 2011 7:15 pm

Re: how to start cron jobs on Qnap?

Post by Dennisonline »

I found ...


crontab /etc/config/crontab
/etc/init.d/crond.sh restart
crontab -l




http://wiki.qnap.com/wiki/Add_items_to_crontab
Post Reply

Return to “Web Server & Applications (Apache + PHP + MySQL / SQLite)”