I have this code in my module_cron function (I need to delete old unpublished nodes).
include_once './modules/node/node.module';
$nids = db_query("SELECT nid FROM node where status = 0 AND UNIX_TIMESTAMP()-changed>172800 LIMIT 2000");
while ($result = db_fetch_object($nids)) {
echo "Deleting node ".$result->nid."<br>";
node_delete($result->nid);
}
It always outputs node ids, but it rarely actually deletes nodes. In fact it seems to totally stop deleting them until I login to admin panel. What am I doing wrong? Is there any way to always delete nodes?