====== Scheduled Tasks ======

SoSci Survey has several time-controlled features, e.g. it can transfer questionnaires to the database when the server is not so busy ([[caching|Caching for Questionnaires]]), send mailings at certain times, or (still in development) provide regular notifications regarding the number of survey participants.

The script ''admin/crontask.php'' has to be run at regular intervals for the scheduled features to work properly. Invoking the script every 5 minutes is recommended - if the script is invoked any less than this, the time the task will be processed will differ greatly from the time you had planned.

To set up the scheduled task, the absolute path of the PHP script is required. Copy this path from **Server Settings** -> **Configuration** → Tab //Server// → //Crontask script//. 

**Note:** [[en:server:maintenance|Regular Maintenance of the Server]] via ''admin/cronjob.php'' has to be performed independently of the cache being transmitted. A reasonable interval here would be 24 hours.


===== Linux =====

Enter the following cronjob to run the script every 5 minutes on a Linux system. Set the password in SoSci Survey in **Server Management** -> **Server Settings**.

<code>
*/5  *  *  *  *  /usr/lib/cgi-bin/php /var/www/html/sosci/admin/crontask.php password=SECRET
</code>

To register the cronjob, use ''crontab''. Create the cronjob for the Linux user (in the example below ''www-data'') that is also used to run the web server. This avoids trouble with file permissions.

<code bash>
sudo crontab -e -u www-data
</code>
===== Windows =====

In Windows, the Task Scheduler is used to regularly run scripts (Scheduled Tasks, Task Scheduler)

An executable file is needed which will be invoked by the PHP interpreter and passed as a parameter by the PHP script. A simple batch file could be used here (''*.bat''). The folder in the following example has to be adapted to fit the respective installation.


<code batch>
C:\php\php.exe C:\webserver\documents\sosci\admin\crontask.php password=SECRET
</code>

Run the file as a test to check the folders. The file will be then be created as a task in the Task Scheduler which will enable it to run regularly.

  * Windows XP: Control Panel -> Scheduled Tasks -> Add Scheduled Task ([[https://www.drupal.org/node/31506|Cron Job in Windows]])
  * Windows 7: Control Panel -> System and Security -> Administrative Tools -> Task Scheduler -> Create Basic Task ([[http://windows.microsoft.com/en-us/windows/schedule-task|Schedule a Task]])
  * Windows 8: Run (Windows button + r) -> type in ''taskschd.msc''  -> OK -> Action -> Create Basic Task ([[http://www.isunshare.com/windows-8/open-windows-8-8.1-task-scheduler.html|Windows 8.1 Task Scheduler]])