Creating node when cron runs I'm a bit new to drupal and I have a task, where I have to create a node when cron runs. I set up the node like this in my custom module's cron hook: 

$node = new stdClass();
$node-&gt;type = 'reports';
$node-&gt;language = LANGUAGE_NONE;
$node-&gt;uid = 1;
$node-&gt;status = 1;
$node-&gt;promote = 0;
$node-&gt;comment = 0;
$node-&gt;sticky = 0;
$node-&gt;moderate = 0;
$node-&gt;title = 'Daily Report for ' . date('d.m.Y');
$node-&gt;field_reporting_cycle[LANGUAGE_NONE][0]['value'] = 1;
$fid = generate_periodic_report(1);
$node-&gt;field_period_of_reporting[LANGUAGE_NONE][0]['value'] = date('Y-m-d', strtotime('-1 days'));
$node-&gt;field_period_of_reporting[LANGUAGE_NONE][0]['value2'] = date('Y-m-d');
$node-&gt;field_reciver[LANGUAGE_NONE][0]['value'] = 2;
$file = file_load($fid);
$file = (array)$file;
$file['display'] = 1;
$node-&gt;field_report_file[LANGUAGE_NONE][] = $file;
node_object_prepare($node);
$node = node_submit($node);
node_save($node);


The node doesn't get created. I don't get any error messages in the log. I don't know what I'm doing wrong.
So I got my answer by myself: I ran clear cache and it performs everything perfectly. @Andrew Morris: I haven't used Rules before but I think it can't be performed by that. The generate function creates 2 xls files via PHPExcel and gets all files uploaded by user in a period of time. Then it compresses all the files into a zip archive via ZipArchive and saves the data for the zip file. Then it returns the fid of the saved file.