2012-01-11 80 views
1

我在擁有多個站點的託管帳戶中擁有5個cron作業的限制。所以我需要把所有的工作分成5套cron作業。被調用的文件都涉及到WordPress插件,feedwordpress和格式將多個PHP作業添加到1個crob作業

/usr/bin/curl --silent http://unique_website.com?update_feedwordpress=1 

所以我計劃有5個cron作業的每個調用這些網站更新的5。任何想法如何實現這一目標?

回答

10

你可以寫一個執行所有curl請求的腳本。

#!/bin/sh 
/usr/bin/curl --silent http://unique_website.com?update_feedwordpress=1 
/usr/bin/curl --silent http://unique_website.com?update_feedwordpress=2 
/usr/bin/curl --silent http://unique_website.com?update_feedwordpress=3 

並改變你的cron任務來執行該腳本。

+0

我還沒有與SH工作之前,我會把什麼文件放進去?(對不起,我知道這是一個蹩腳的問題。我從主機上的cron中增加了一些東西,我將它指向:/ usr/bin/curl --silent http://unique_website.com /cron.sh – 2012-01-11 20:43:05

+1

這段代碼應該放在文件中,cron作業應該是/ bin/sh/path/to/script.sh或可能是/ bin/bash/path/to/script。 sh'。如果你可以製作cript的可執行文件,你可以通過簡單的'/ path/to/script.sh'來獲得。 – jprofitt 2012-01-11 20:44:52

+0

謝謝你會給它一個鏡頭 – 2012-01-11 20:50:02

0

你也可以做類似

/usr/bin/curl --silent --config /path/to/your/config 

,讓您的配置文件看起來像

#Update wordpress #1 
url = 'http://unique_website.com?update_feedwordpress=1' 

#Update wordpress #2 
url = 'http://unique_website.com?update_feedwordpress=2' 

#more ... 

其中有被「射後不理」,爲的cronjob的優勢,如果你需要改變只需更改配置文件。 Ofcourse,你也可以從PHP

寫您的配置文件
0

順便說一句,捲曲,你可以做這些事情:

/usr/bin/curl --silent http://unique_website.com?update_feedwordpress=[1-5] 
/usr/bin/curl --silent http://unique_website.com?update_feedwordpress={1,2,3,5} 
/usr/bin/curl --silent http://{unique,other,third}_website.com?update_feedwordpress=1 

它將捲曲多次調用不同的參數