php arka plan işlemi PID sorun

0 Cevap php

Ben bu script var ve bunu çalıştırırsanız ben üst komutu ile listelenen birinden veritabanına girilen farklı bir PID numarası almak:

<?php
error_reporting(0);

include_once "config/mysql.php";

// the path
$path = "PATH=$PATH:/share/MD0_DATA/.qpkg/Optware/bin:";

//random number for the log file name
$random = rand(1,500000);

//initial download location
$init_loc="/share/MD0_DATA/Qdownload/plowshare";

$items = rtrim($_POST['items'],",");
$sql = mysql_query("SELECT url, pid FROM plow WHERE id IN ($items)") or die ('Error: ' . mysql_error());

while ($db_row = mysql_fetch_assoc($sql)) { 
  //random number for the log file name
  $random = rand(1,500000);
  //log file name
  $out_file = '/share/MD0_DATA/Qdownload/plowshare/Logs/log'.$random.'.txt';
  //command 1
  $command = exec("($path" . " nohup /opt/bin/plowdown -o '$init_loc' " . "'".$db_row['url']."' 2> " . "'$out_file' > /dev/null &);" . "echo $$;", $out); 
  exec($command, $out);
  $query = mysql_query("UPDATE plow SET state = 'Active', pid = '$out[0]' WHERE id IN ($items)") or die ('Error: ' . mysql_error());
 }
mysql_close();

?>

Sonuç her zaman aynıdır:

Veritabanına girilen Pid numarası: 11159 (random sayı, sadece bir noktayı şimdi seçilmiş)

Üst commnand listelenir Pid numarası: 11161.

Üst komutu ile listelenen PID numarası her zaman 2 ile veritabanından bir sonra daha büyük.

Bu beni deli ediyor ...

Teşekkürler,

Cristian.

0 Cevap