Take care if you use getcwd() in file that you'll need to include (using include, require, or *_once) in a script located outside of the same directory tree.
example:
<?php
if (strpos(getcwd(),'main_')>0) {
}
?>
<?php
require_once ('/var/www/main_document_root/include/MySQL.inc.php');
?>
In the above example, the database connection will not be made because the call to getcwd() returns the path relative to the calling script ( /home/cron_user/maintenance_scripts ) NOT relative to the file where the getcwd() function is called.