Regarding setting cron job

More
1 year 1 month ago #142072 by bava
bava created the topic: Regarding setting cron job
hi,
i want to run a cron job on daily basis which may interact with database tables inserting and updating , how to do it with limesurvey version 2.50+ . adding a controller like CronController is not working, and how to write a crontab command in linux .
Thanks

Please Log in to join the conversation.

More
1 year 1 month ago #142075 by jelo
jelo replied the topic: Regarding setting cron job

bava wrote: i want to run a cron job on daily basis which may interact with database tables inserting and updating , how to do it with limesurvey version 2.50+ . adding a controller like CronController is not working, and how to write a crontab command in linux .
Thanks

What kind of script/program do you use to interact with database tables?
You will have to create a script/programm/command first.

Then you create a cronjob.
Depending on your operatingsystem and serversettings there might be different ways to do it.
A good introduction is here:
www.pantz.org/software/cron/croninfo.html

Please Log in to join the conversation.

More
1 year 1 month ago #142077 by bava
bava replied the topic: Regarding setting cron job
class CronController extends LSYii_Controller
{
public $layout='bare';
public function actionTestCron()
{
//code stuffs goes here
}
}

cron command crontab :
*/5 * * * * php -q /path/to/domain/public_html/application/controllers/cron/testcron 2>>/var/www/domain/public_html/testcron.log


thanks.

Please Log in to join the conversation.

More
1 year 1 month ago #142083 by jelo
jelo replied the topic: Regarding setting cron job
Any error logs? I would start from the command line:

What is the output of:
php /path/to/domain/public_html/application/controllers/cron/testcron

Before digging into details of Yii and Limesurvey get a simple php command running.
Sometime there are serverside restrictions or some path mistypes etc.

With Yii specific stuff I am not competent enough.
But you should post the exact version/build of LimeSurvey you're using.

Please Log in to join the conversation.

More
1 year 1 month ago - 1 year 1 month ago #142085 by bava
bava replied the topic: Regarding setting cron job
versionnumber' = "2.50+"
dbversionnumber'] = 258;
'buildnumber'] = 160517;

error log is empty without any error messages, is there any file to put in server like cron.php under public_html using the digital ocean server

Thanks
Last Edit: 1 year 1 month ago by bava.

Please Log in to join the conversation.

More
1 year 1 month ago #142086 by jelo
jelo replied the topic: Regarding setting cron job
What was the result of executing
"php /path/to/domain/public_html/application/controllers/cron/testcron" from the commandline?

You can check if php ins running from cli via e.g.
php -i > phpinfo.txt

Please Log in to join the conversation.

More
1 year 1 month ago #142090 by bava
bava replied the topic: Regarding setting cron job
i didn't check this by command line , for testing purpose i am creating a text file , by entering url like www.xyz.com/controller/action is working fine.
but when i trying by crontab it won't work

Please Log in to join the conversation.

More
1 year 1 month ago #142091 by jelo
jelo replied the topic: Regarding setting cron job

bava wrote: i didn't check this by command line , for testing purpose i am creating a text file , by entering url like www.xyz.com/controller/action is working fine.

Well if you want a behaviour like accessing via a Webbrowser you should try curl instead of php as a command.

But since you use php with crontab you are executing via commandline.
To check that, you can execute "php /path/to/domain/public_html/application/controllers/cron/testcron" from the commandline and see if that runs without a glitch. If that works fine, start with crontab.If not, the issue is not with crontab.

Please Log in to join the conversation.

More
1 year 3 weeks ago #142464 by DenisChenu
DenisChenu replied the topic: Regarding setting cron job
We have a plugin system for this : manual.limesurvey.org/Cron

Exemple of usage : github.com/SondagesPro/LS-sendMailCron

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 year 3 weeks ago #142500 by jelo
jelo replied the topic: Regarding setting cron job

DenisChenu wrote: We have a plugin system for this : manual.limesurvey.org/Cron

How does the plugin system solve the issue with crontab not executing the php script?

Please Log in to join the conversation.

More
1 year 2 weeks ago - 1 year 2 weeks ago #142575 by LouisGac
LouisGac replied the topic: Regarding setting cron job
well, the reason why your code doesn't work is because LimeSurvey doesn't strictly respect the Yii way of doing, in this case, the routing system (and plugin system make the problem even worst, because plugins doesn't extend any of the Yii classes, and their routing is a true horror).

In one of the future LS major release, this will be fixed, so it will be possible to modify LimeSurvey following the excellent Yii documentation (and to serve Yii module as LimeSurvey plugins).

For now, if you want to add a new controller with new actions, I'd suggest you to have a look how I did it for the home page setting:
github.com/LimeSurvey/LimeSurvey/blob/ma...homepagesettings.php
github.com/LimeSurvey/LimeSurvey/blob/ma...nController.php#L206
Last Edit: 1 year 2 weeks ago by LouisGac.

Please Log in to join the conversation.

More
1 year 2 weeks ago #142578 by DenisChenu
DenisChenu replied the topic: Regarding setting cron job
@LouisGac :

bava wrote: hi,
.... adding a controller like CronController is not working, ....

I make the same error ....

bava wrote: ..... how to write a crontab command in linux.


@bava : see en.wikipedia.org/wiki/Cron

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 year 2 weeks ago #142603 by jelo
jelo replied the topic: Regarding setting cron job

LouisGac wrote: well, the reason why your code doesn't work is because LimeSurvey doesn't strictly respect the Yii way of doing,

Bava stated, that his code is working when accessing it via URL.

"by entering url like www.xyz.com/controller/action is working fine."

Only when trying to execute it via a cronjob the script isn't working.
But since the threadstarter is no longer commenting, I'm out.
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now