2017-04-05 178 views
0

我有一個腳本,我想每天更新。所以我必須使用crontab。我如何使用Crontab運行腳本?MongoDB - 使用Crontab運行腳本

UPDATE

我使用Ubuntu。

script file

+1

編寫,通過MongoDB的運行查詢一個bash文件,然後安排在bash (.sh)與crontab的cronjob文件。你使用的是什麼版本的linux,請發佈你的bash文件 – Jpsh

+1

這應該能解決你的查詢。 http://stackoverflow.com/questions/19754784/running-a-simple-shell-script-as-a-cronjob –

+0

我會審查和嘗試。 @RahulLakhanpal – forguta

回答

1

假設你想使用你在上午12:15 bash腳本每天更新。 然後一個條目添加到/etc/crontab這樣

15 0 * * * /home/your_bash_script.sh 

只是爲了更多的信息,被添加在cron時間條目

* * * * * * <your-bash-script-path> 
| | | | | | 
| | | | | +-- Year    (range: 1900-3000) 
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday) 
| | | +------ Month of the Year (range: 1-12) 
| | +-------- Day of the Month (range: 1-31) 
| +---------- Hour    (range: 0-23) 
+------------ Minute   (range: 0-59) 
+0

我對cron沒有任何問題。我只有創建我的bash文件時遇到問題。如何將任何腳本文件轉換爲bash? – forguta

+0

您正在使用ubuntu,因此任何使用bash命令且最後具有.sh文件擴展名的文件都是bash腳本。 –