I am executing cron.php the recommended way - via PHP's CLI instead of accessing it with a browser, having browser access completely disallowed (Site Administration -> Security -> Site policies -> Cron execution via command line only: Yes). My crontab entry is:
*/30 * * * * php -d safe_mode="off" -d open_basedir="" /path_to/moodle/admin/cron.php > /dev/null
However, this writes a warning to STDOUT, which will then get emailed every time:
PHP Notice: Undefined index: REMOTE_ADDR in /path_to/moodle/lib/moodlelib.php on line 7513
The notice of course does not harm, it is annoying however to receive all these emails. Thus, the code should be cleaned ensuring not producing any notice/warning.