If it works when the user triggers it through loading a file, but not through the cron job then there are only 2 possible reasons...

  • User privileges in the cron job
  • Incorrect cron job setup