perform action if user is not logged in for 24 hours I wrote this script using poor man's cron to send an email in 24 hours if a user has not logged in during that amount of time. It works but I can't figure out why after 24 hours passes the email sends, but then it starts sending again every hour.   

function dreamcharts_cron() {
      $now = time();
      $result = db_query("SELECT u.uid, u.mail, u.access 
                      FROM {users} u
                      INNER JOIN {users_roles} ur ON ur.uid = u.uid
                      WHERE ur.rid = 4 AND u.uid NOT IN (0,1)");
      $i = 0;
      while($user = db_fetch_object($result)) {
        if ($user-&gt;access + 86400 &lt; $now) {

         // drupal_set_message('&lt;pre&gt;' . print_r($user-&gt;mail, 1) . '&lt;/pre&gt;');  
               $message = array(
            'to' =&gt; $user-&gt;mail,
            'subject' =&gt; 'you have not logged in in 24 hours',
            'body' =&gt; t('Please log into your Account Today', array('@title' =&gt; $title)),
            'headers' =&gt; array(t('From') =&gt; variable_get('site_mail', ini_get('sendmail_from'))),
               );
              drupal_mail_send($message);
          $i++;

      }  
      }
      }
It is sending every hour because cron is running every hour, and the user has not yet logged in to change the timestamp. There is no check to see if the email has been sent, or when it was sent.

You can either update the user's timestamp to $now, which will stop the email from being sent for the next 24 hr., or set a flag on the account to say that an email has been sent.