나는 centos 서버에서 일하고 있는데 tbz 형식의 centos 서버에 다른 서버에서 데이터를 다운로드해야합니다. 그리고 추출해야하고 추출 완료 후 데이터를 가져와야합니다. 그것에서 mysql 데이터베이스 테이블.PHP 스크립트에서 centos 명령을 실행
내가하고있는 일은 크기가 약 700MB 인 서버에서 데이터를 가져 오는 중, 명령을 실행할 때 다른 사람이 아무 일도 일어나지 않을 때 데이터를 가져옵니다.
$files = array('20111101.tbz', '20111101.tbz.md5' ,'20111102.tbz' ,'20111102.tbz.md5') ;
//folder names of the folders formed
$folder1 = "20111101";
$folder3 = "20111102";
//command to extract all the downloaded .tbz files
$command1 = "cd /var/www/html/mywork1/mywork2/mywork3/";
exec($command1." 2>&1", $output);
$command2 = "tar -xjf ".$files[0];
exec($command2." 2>&1", $output);
$command4 = "tar -xjf ".$files[2];
exec($command4." 2>&1", $output);
//command to populate the data into the database
$command6 = "cd /var/www/html/mywork1/mywork2/mywork3/mywork4";
exec($command6." 2>&1", $output);
$command7 = "./runit.py /var/www/html/mywork1/mywork2/mywork3/$folder1";
exec($command7." 2>&1", $output);
$command9 = "./runit.py /var/www/html/mywork1/mywork2/mywork3/$folder3";
exec($command9." 2>&1", $output);
//command to remove the folders created after population of data
$command10 = "rm -rf $folder1";
exec($command10." 2>&1", $output);
$command11 = "rm -rf $folder3";
exec($command11." 2>&1", $output);
foreach ($files as $file)
{
//command to remove all .tbz files downloaded.
$command12 = "rm -rf $file";
exec($command12." 2>&1", $output);
}
나는 단순히 명령을 실행하고 있지만 아무 것도하지 않습니다. 그러나 서버에서 수동으로이 모든 명령을 시도해도 제대로 작동합니다. 아무도 이것에 대해 안내 할 수 있습니까? 이것을하기위한 올바른 접근 방법은 무엇입니까?
왜이 태그는 "파이썬"입니까? – Johnsyweb
당신의 문제는 당신이 무슨 일이 일어나고 있는지 모른다는 것입니다. 그래서'display_errors'를 활성화시키고,'error_reporting'을'-1'로 설정하십시오. 또한'exec' ('echo $ output;') 다음에 명령 출력을 표시하십시오. 귀하의 웹 서버 사용자는 해당 디렉토리에 대한 쓰기 액세스 권한을 갖고 있습니까? – vstm
질문에 답하지 않고 Bash 스크립트에 모든 명령을 넣고 PHP 스크립트에서 실행 해 보았습니까? –