2016-04-01 27 views
0

PHPファイルをパス/var/www/html/rss_feed/mirror.phpにcronタブで実行しようとしています。このため私は以下の手順を実行しました。 PHPスクリプトを実行するためのCrontabのスケジュール

sudo crontab -e 

は、その後、私はあなたが以下を参照することができますPHPファイルを実行するごとに2分後にcronタブをスケジュールするために挿入されたコードの行があるので、次のコード

# Edit this file to introduce tasks to be run by cron. 
# 
# Each task to run has to be defined through a single line 
# indicating with different fields when the task will be run 
# and what command to run for the task 
# 
# To define the time you can provide concrete values for 
# minute (m), hour (h), day of month (dom), month (mon), 
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system 
# daemon's notion of time and timezones. 
# 
# Output of the crontab jobs (including errors) is sent through 
# email to the user the crontab file belongs to (unless redirected). 
# 
# For example, you can run a backup of all your user accounts 
# avt 5 a.m every week with: 
# 0 5 * * 1 tar -zcf /ar/backups/home.tgz /home/ 
# 
# For more information see the manual pages of crontab(5) and cron(8) 
*/2 * * * * /usr/bin/php /var/www/html/rss_feed/nbt_times.php 
# 
# m h dom mon dow command 

を挿入することで、ファイルを編集しました。

*/2 * * * * /usr/bin/php /var/www/html/rss_feed/nbt_times.php 

私も

2 * * * * lynx -dump http://192.168.0.232/rss_feed/mirror.php > /dev/null 2>&1 

もこの

2 * * * * /your/path/to/php /var/www/html/rss_feed/nbt_times.php 

と異なる記事からより多くのフォーマットを以下試してみました。

PHPスクリプトが実行されていません。コードを別の場所に置く必要がありますか?それとも、私は間違った方向にいる。あなたは何が問題であるかを知るのを助けてくれますか?

+0

エラーログを確認しますか? –

+0

エラーログにもエントリがありません。私はmirror.phpを探しました。しかし、何も得られなかった –

+0

コマンドラインからPHPファイルを実行する - それは動作しますか? – Andrew

答えて

0

それは動作しますが、ここにいくつかの明確化を取得する必要があるのは、ファイル名が異なる1時間のようですそのmirror.php、別の時間にそのnbt_times.php PHPファイルがあり、特定の時間に実行する必要があり

指定する。 /var/www/html/rss_feed/mirror.phpを実行していることを指定したら、最初のコマンドでmirrror.phpを指定します。

2番目と3番目のコマンドは、毎時2分のジョブを実行します。 (4:02,5:02,6:02など)のような

すべての2分は、この作品を願ってのためにこれを実行します。このcrontabの

*/2 * * * * /usr/bin/php /var/www/html/rss_feed/mirror.php 

を試してみてください。

0

試しのphp5-cliを:

*/2 * * * * /usr/bin/php5-cli -f /var/www/html/rss_feed/nbt_times.php 

はまた、ログへの書き込みを追加し、分後にそれらを参照してください:あなたのphpファイルの

* * * * * /usr/bin/php /var/www/html/rss_feed/nbt_times.php >>log.log 2>>log.err 

のアクセス権を確認します。チェックのため0777にしてください。ある行でもっとも簡単なPHPファイルを作成し、cronで実行してみてください。

+0

/usr/bin/phpがcliのバージョンです。それをチェックするためだけに777にしないでください。ちょうどsudo chmod + x/usr/bin/phpを実行します。 – Zarathuztra

+0

@Zarathuztra私は実行可能なPHPファイル(チェックする)上で777を意味します... – jekaby