title: Crontab and PHP require_once not working well
body: <p>So I have a cron tab set up</p>
  
  <pre><code>SHELL=/bin/bash
  PATH=/sbin:/bin:/usr/sbin:/usr/bin
  MAILTO=root
  HOME=/
  
  # For details see man 4 crontabs
  
  # Example of job definition:
  # .---------------- minute (0 - 59)
  # |  .------------- hour (0 - 23)
  # |  |  .---------- day of month (1 - 31)
  # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
  # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
  # |  |  |  |  |
  # *  *  *  *  * user-name command to be executed
    40 14 *  *  * root php /home/sites/sitename/batch/sendemailtest.php
  </code></pre>
  
  <p>Now here is the problem, when I run <code>php sendemailtest.php</code> inside the batch directory, everything works fine. But if I run it from any other directory like  <code>php /home/sites/sitename/batch/sendemailtest.php</code> it gives me trouble. </p>
  
  <p>I think it's because inside that php file is a <code>require_once</code>:</p>
  
  <pre><code>require_once '../includes/dbpw.php';
  </code></pre>
  
  <p>So I am guessing the location I call the php file messes everything up.</p>
  
  <p>How do I fix this? </p>
  
  <p>I haven't tried this yet, in fear it will have unintended results... but if I change <code>HOME=/</code> to <code>HOME=/home/sites/sitename/batch/</code>, then have it run <code>php sendemailtest.php</code>, would that work?</p>