Toolserver:PHP

PHP scripts can be left running on the server using a screen session and can be scheduled to run at set times using cron.

PHP scripts must be modified to run directly on the server: they cannot use $_POST or $_GET variables.

Debugging
To debug a PHP script which crashes (with a segmentation fault), type: $ gdb php-cgi $ run myscript.php Then wait for your script to run. When it crashes, type: $ bt

Another mechanism to debug is running your script from the command line using -l: $ php -l myscript.php

It's also possible (usually) to configure PHP to be more descriptive when outputting its error messages by adding the following lines to the top of the PHP file: error_reporting(E_ALL); ini_set("display_errors", 1);

flush does not work!
flush does not work. To be precise: flush does work but a layer of buffering outside the PHP interpreter makes it appear to not work. Circumvention: send a lot of whitespace characters after the output that you want flushed - a total length of useful_text + whitespace greater than 8192 bytes should be sufficient. (Clearly, sending whitespace is a waste of bandwidth so this trick should be used sparingly.)