- Posts: 10
- Thank you received: 0
Regarding setting cron job
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 .
What kind of script/program do you use to interact with database tables?
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 .
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:
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
What is the output of:
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.
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
"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
but when i trying by crontab it won't work
Well if you want a behaviour like accessing via a Webbrowser you should try curl instead of php as a command.
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.
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.
Exemple of usage : github.com/SondagesPro/LS-sendMailCron
How does the plugin system solve the issue with crontab not executing the php script?
DenisChenu wrote: We have a plugin system for this : manual.limesurvey.org/Cron
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:
I make the same error ....
bava wrote: hi,
.... adding a controller like CronController is not working, ....
bava wrote: ..... how to write a crontab command in linux.
@bava : see en.wikipedia.org/wiki/Cron
Bava stated, that his code is working when accessing it via URL.
LouisGac wrote: well, the reason why your code doesn't work is because LimeSurvey doesn't strictly respect the Yii way of doing,
Only when trying to execute it via a cronjob the script isn't working.
"by entering url like www.xyz.com/controller/action is working fine."
But since the threadstarter is no longer commenting, I'm out.
Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support