Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Regarding setting cron job

More
7 years 6 months ago #142072 by bava
Regarding setting cron job was created by bava
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
The topic has been locked.
More
7 years 6 months ago #142075 by jelo
Replied by jelo on 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

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
More
7 years 6 months ago #142077 by bava
Replied by bava on 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.
The topic has been locked.
More
7 years 6 months ago #142083 by jelo
Replied by jelo on 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.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
More
7 years 6 months ago - 7 years 6 months ago #142085 by bava
Replied by bava on 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: 7 years 6 months ago by bava.
The topic has been locked.
More
7 years 6 months ago #142086 by jelo
Replied by jelo on 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

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
More
7 years 6 months ago #142090 by bava
Replied by bava on 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
The topic has been locked.
More
7 years 6 months ago #142091 by jelo
Replied by jelo on 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.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 6 months ago #142464 by DenisChenu
Replied by DenisChenu on 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 , plugin development .
I don't answer to private message.
The topic has been locked.
More
7 years 6 months ago #142500 by jelo
Replied by jelo on 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?

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
7 years 6 months ago - 7 years 6 months ago #142575 by LouisGac
Replied by LouisGac on 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: 7 years 6 months ago by LouisGac.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 6 months ago #142578 by DenisChenu
Replied by DenisChenu on 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 , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose