Hi,
This is my first post here and i am not sure if i am posting in the correct Sub-Forum. Sorry if it is the wrong place:)
I am trying to run a cronjob with phyton to call a controller action "publishPages". The output on the Debian commandline is correct, but the doPublish(); doesn't seem to do anything.
If i call the Controller-Action through a browser it gives the same output and publishes the relevant Pages correctly.
Hope somebody can give me a hint. Here is my controller code and the phyton call below:
Note: The echo - outputs work as well from the terminal phython call. But no publish happens...
CronController.php
class CronController extends Controller{
function publishPages(){
$pages = DataObject::get("Page");
$today = strtotime(date('Y-m-d'));
foreach($pages as $page) {
if($page->PublishOnDate){
$publishOn = strtotime($page->PublishOnDate);
$pageSitetree = DataObject::get_by_id('SiteTree',$page->ID);
if($publishOn <= $today){
if(isset($pageSitetree->ID) && $pageSitetree->Status != "Published"){
echo "publish:".$pageSitetree->Title."</br>";
$page->doPublish();
}
}else{
echo "to early for:".$pageSitetree->Title."</br>";
}
}
}
}
}
phython call from debian terminal:
phython -c "import urllib2;print urllib2.urlopen('http://someurl/CronController/publishPages').read()"
Thanks for your help in advance