2013-07-27 2 views
0

나는 cron 작업으로 심포니 명령을 추가하고 싶어하지만 내 호스팅 서버 (2freehosting.com) 나 다음 명령을 추가 할 수 없습니다 :의실행 심포니는 PHP 파일에서이 명령은

php app/console cache:clear --env=prod --no-debug 

php path/to/file 유형을 명령이 허용됩니다.

그래서 나는 위의 명령을 실행하고

php path/to/clearCache.php 

가 어떻게 clearCache.php이 심포니 명령을 호출 할 수 있습니다 cron 작업으로 추가 할 파일 clearCache.php을 만들려면?

alias symfony-cc="php path/to/app/console cache:clear --env=prod --no-debug" 

답변

1

사용할 수있는 bash는 스크립트 당신이 리눅스를 사용하는 가정

#!/bin/bash 

/path/to/php /path/to/app/console cache:clear --env=prod --no-debug 
0

clearCache.sh 같은, 당신이 별칭을 만들 수 있습니다

내 디렉토리 구조

캐시 지우기는 app/cache에서 폴더 및 파일을 제거하는 것을 의미합니다. 그래서 당신은 웹 폴더에 clear.php 파일을 만들고이 트릭

를 사용하여 넣을 수 있습니다

<?php // get all file names 
$str = __DIR__.'/../app/cache/'; 

function recursiveDelete($str){ 
if(is_file($str)){ 
    return @unlink($str); 
} 
elseif(is_dir($str)){ 
    $scan = glob(rtrim($str,'/').'/*'); 
    foreach($scan as $index=>$path){ 
     recursiveDelete($path); 
    } 
    return @rmdir($str); 
} 
} 

recursiveDelete($str); 

//here you can redirect to any page 
echo(__DIR__.'/../app/cache/*'.' -> Clear completed'); 

그런 다음 로컬 호스트/clear.php 또는 yoursite.com/clear.php의 접근

0

기억 :

-app 
-bin 
-vendor 
-src 
-public_html 
    -bundles 
    -app.php 
    ..... 
-clearCache.php