2014-02-28 66 views
0

我有它運行在Ubuntu Linux服務器LTS shell腳本12.0.04每2個mintues建立彈性搜索索引cron作業,下面是shell腳本:cron作業彈性搜索(FOS彈性束)

#! /bin/sh 
echo "--------------------------------------------------------------" >> /var/log/syslog ; 
echo "     CRON Task: DOCOVA Elastic Indexer DV  " >> /var/log/syslog ; 
echo "--------------------------------------------------------------" >> /var/log/syslog ; 
echo "populate index ..." >> /var/log/syslog ; 
echo "start time: $(date)" >> /var/log/syslog; 
/usr/bin/php /var/www/Symfony/app/console fos:elastica:populate --no-reset -v >> /var/log/syslog; 
#php app/console fos:elastica:populate >> /var/log/syslog; 
echo "index task completed." >> /var/log/syslog ; 
echo "end time: $(date) " >> /var/log/syslog; 
echo "-------------------------------------------------------------" >> /var/log/syslog ; 

當該腳本通過它似乎給瞭如下圖所示的輸出,具有較高數量的cron作業運行「填充網頁/文件,100.0%(30/30),144個對象/ S」

Feb 28 11:58:01 ubuntu-teitr CRON[5138]: (root) CMD (/var/www/Symfony/buildDocovaIndex.sh) 
-------------------------------------------------------------- 
         CRON Task: DOCOVA Elastic Indexer DV 
-------------------------------------------------------------- 
populate index ... 
start time: Fri Feb 28 11:58:01 EST 2014 
command: php /var/www/Symfony/app/console fos:elastica:populate --env=prod 
Populating website/documents, 100.0% (30/30), **144 objects/s** 
Refreshing website 
index task completed. 
end time: Fri Feb 28 11:58:01 EST 2014 
------------------------------------------------------------- 

當我手動運行該腳本時,它具有較低數量的對象計數,如下所示:

populate index ... 
    start time: Fri Feb 28 12:09:08 EST 2014 
    command: php /var/www/Symfony/app/console fos:elastica:populate --env=prod 
    Populating website/documents, 100.0% (30/30), **12 objects/s** 
    Refreshing website 
    index task completed. 
    end time: Fri Feb 28 12:09:10 EST 2014 

有人可以建議爲什麼會發生這種不一致的行爲,是否有需要添加到shell腳本的東西,請指教,thnx。

回答

0

我能夠通過Cron時間表首先使用CD「CD /無功/網絡/ Symfony的」改變路徑來解決這個,如下所示:

*/2 * * * * cd /var/www/Symfony && /var/www/Symfony/buildDocovaIndex.sh