title: How to check if I have an active login session with Ruby and cron?
body: <p>I have a cron task that calls a Ruby script every minute. But I don't want the script to do anything, unless I'm logged in.</p>
  
  <p>I found this snippet in the internet, to be placed in the beginning of the script:</p>
  
  <pre><code>exit unless `who -q`.include? ENV['USER']
  </code></pre>
  
  <p>The problem is that only works when I call the script myself. When it runs from cron, Postfix sends me this message:</p>
  
  <pre><code>`include?': can't convert nil into String (TypeError)
  </code></pre>
  
  <p>Doesn't <code>who -q</code> return anything for a cron job? What can I do in this case?</p>