For the correct operation of SoSci Survey, the automated regular execution of two scripts is recommended:
Some tasks have to be done regularly on the survey server: archiving old projects, deleting temporary files, deleting obsolete user accounts (dead accounts), and optimizing the database tables.
These tasks are done by a maintenance script /admin/cronjob.php. This script is protected by a password, which you can set in the Server Settings under Configuration. The password is passed to the script as parameter password.
You will find the complete path of the PHP script under Server Settings → Configuration → tab System Settings → Maintenance script.
The server maintenance can also be performed manually, for example on servers that are rarely used.
The PHP script returns the following messages:
ok – Cronjob done, everything is finewarning – Cronjob done, there were warningserror – Cronjob done, there were errorsdenied – the password is not correct (if specified)delayed – the cronjob has been run within the last 6 hours and does not need to be run again yetThe server administrator receives an email with further details on the cronjob, which also lists uploaded files, new user accounts, and projects. Some information from the cronjob (e.g., deleted users and projects) is also recorded in the cronjob logfile.
SoSci Survey offers some scheduled functions, e.g., transferring interviews to the database when the server load is low (Write Cache for Interviews), the scheduled dispatch of mailings, or (still in development) regular notifications about the number of survey participants.
For the scheduled functions to work correctly, the script admin/crontask.php has to be run regularly. Calling it every 1-5 minutes is recommended – if you call the script less often, the time at which a task is processed may deviate more from the scheduled time.
You will find the absolute path to the PHP script, which you need for setting up the scheduled execution, under Server Settings → Configuration → tab System Settings → Crontask script.
Create two bash scripts, for example in var/www/script/, with the following content. Replace /var/www/html/ with the installation directory of SoSci Survey and PASSWORT with the Password for cronjob set in the Server Settings.
#!/bin/bash cd /var/www/html/admin/ /usr/bin/php /var/www/html/admin/cronjob.php password=PASSWORT
#!/bin/bash cd /var/www/html/admin/ /usr/bin/php /var/www/html/admin/crontask.php password=PASSWORT
www-data. In addition, the scripts need the “executable flag”.sudo chown www-data cronjob.sh crontask.sh sudo chmod u+x cronjob.sh crontask.sh
php may vary, e.g., /usr/lib/cgi-bin/php. You can determine the correct path, for example, by means of which php.sudo -u www-data /s2data/s2survey/script/crontask.sh
sudo crontab -u www-data -e# m h dom mon dow command */1 * * * * /var/www/script/crontask.sh >/dev/null 2>&1 30 4 * * * /var/www/script/cronjob.sh >/dev/null 2>&1
On Windows, the Task Scheduler is responsible for the regular execution of scripts (scheduled tasks, task scheduling).
First, an executable file is required that calls the PHP interpreter and passes the PHP script as a parameter – for example, a simple batch file (*.bat). The paths in the following example have to be adapted to the respective installation.
C:\php\php.exe C:\webserver\documents\sosci\admin\crontask.php password=PASSWORT
C:\php\php.exe C:\webserver\documents\sosci\admin\cronjob.php password=PASSWORT
Run the file as a test to check the paths. The regular execution of this file is then created as a task in the Task Scheduler.
In the Task Scheduler
crontask.batcronjob.bat