tmpwatch 라는 명령

일정 시간동안 접근이 없는 파일 삭제하기
 

yum -y install tmpwatch


[root@howtounix hack]# ll
total 16
-rwxr-xr-x 1 root root 8486 Aug 24 17:36 a.out
-rw-r--r-- 1 root root 1044 Aug 24 15:42 test.c

24시간 이후로 접근이 없는 파일들 삭제

[root@howtounix hack]# tmpwatch --atime 24 ./
[root@howtounix hack]# ll
total 0


간단하네.

       -u, --atime
              Make the decision about deleting a file based on the file’s atime (access time). This is
              the default.

              Note that the periodic updatedb file system scans keep the atime of directories  recent.

       -m, --mtime
              Make  the  decision  about deleting a file based on the file’s mtime (modification time)
              instead of the atime.

       -c, --ctime
              Make the decision about deleting a file based on the file’s ctime  (inode  change  time)
              instead of the atime; for directories, make the decision based on the mtime.

       -M, --dirmtime
              Make  the  decision about deleting a directory based on the directory’s mtime (modifica-
              tion time) instead of the atime; completely ignore atime for directories.

[출처] https://opentutorials.org/module/981/8083

'Works > CentOS & RockyLinux' 카테고리의 다른 글

CentOS 다운로드 미러 사이트  (0) 2017.01.03
CentOS7 hostname 설정  (0) 2016.10.31
du 명령어의 활용  (0) 2016.09.02
필요한 rpm 패키지를 다운받자  (0) 2016.08.03
xferlog 항목별 분석  (0) 2016.07.27

#!/bin/bash                                                   #!/bin/bash

string='www.sysadm.kr';                                     string='www.sysadm.kr';


if [[ $string == *"sysadm"* ]]                            if [[ $string =~ .*sysadm.* ]]
then                                                           then
  echo "It's there!";                       또는              echo "True"
else                                                            else
echo "There is no String!"                                   echo "False"
fi                                                               fi



grep -A n pattern datafile
grep -B n pattern datafile

grep -C n pattern datafile

을 사용하면 된다.


n 은 0과 자연수 (1,2,3,4....n)


aa.txt 내용

apple
orange
banana
mango


-A 옵션은 match된 line의 다음 n line을 추가로 출력하여 준다.  (After)

    ex) grep -A 2 orange aa.txt -> orange부터 2라인 아래까지 출력 (orange부터 mango 까지 출력된다.)


-B 옵션은 match 된 line의 전 n line을 추가로 출력하여 준다. (Before)

    ex) grep -B 2 banana aa.txt -> banana부터 2라인 위까지 출력 (banana부터 apple 까지 출력된다.)


-C 옵션은 match 된 line의 이전&다음 n line을 추가로 출력하여 준다. (Before & After)

    ex) grep -C1 banana aa.txt -> banana부터 위아래로 1라인씩 추가로 출력하여 준다.

        (orange부터 mango까지 출력된다.)

    또는 grep -A1 -B1 banana aa.txt 로 하여도 결과는 동일하다.


PHP에서 MS-SQL 서버를 연동하기 위한 방법입니다

- PHP의 mssql extension을 컴파일 하기 위해서는 FreeTDS 라이브러리가 필요합니다.
  본문에서는 APM은 이미 설치되어 있는 것으로 가정하고 Freetds는 소스 설치, mssql 모듈은 extension으로 설치 하겠습니다.


(1) FreeTDS 설치

   # wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz

   # tar xvzf freetds-stable.tgz

   # cd freetds-0.91

   # ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --disable-odbc --disable-debug --enable-msdblib

   # make && make install

 

(2) freetds.conf 설정 및 ms-sql 접속 Test

   # vi /usr/local/freetds/etc/freetds.conf

 

- 아래의 항목 추가

   [TestMSSQL]
   host = IP주소
   port = 1433
   tds version = 8.0
   client Charset = UTF-8
  * tds version : 접속 하고자 하는 SQL Server 버젼에 맞게 수정.


(3) MS-SQL 접속 테스트

   # /usr/local/freetds/bin/tsql -H ip주소 -p 1433 -U db계정 -P 비밀번호


(4) mssql 모듈 설치

   # cd /usr/local/src/php-5.2.9/ext/mssql

   # /usr/local/php/bin/phpize

   # ./configure --with-mssql=/usr/local/freetds --with-php-config=/usr/local/php/bin/php-config

   # make

   # cp .libs/mssql.so /PHP Extension 디렉토리

   # vi /usr/local/php/lib/php.ini
     extension=mssql.so <---- 추가

    # apache 재구동


(5) 모듈 설치 확인 - phpinfo의 mssql 항목 확인 및 php -i 옵션으로 확인

   # /usr/local/php/bin/php -i | grep mssql
   mssql
   mssql.allow_persistent => On => On
   mssql.batchsize => 0 => 0
   mssql.charset => no value => no value
   mssql.compatability_mode => Off => Off
   mssql.connect_timeout => 5 => 5
   mssql.datetimeconvert => On => On
   mssql.max_links => Unlimited => Unlimited
   mssql.max_persistent => Unlimited => Unlimited
   mssql.max_procs => Unlimited => Unlimited
   mssql.min_error_severity => 10 => 10
   mssql.min_message_severity => 10 => 10
   mssql.secure_connection => Off => Off
   mssql.textlimit => Server default => Server default
   mssql.textsize => Server default => Server default

   mssql.timeout => 60 => 60

[mssql 접속을 위한 테스트 페이지 샘플]

<?php
 
   putenv("FREETDSCONF=C:\freetds.conf");  // 이 두줄은 빼도 되면 빼고 안되면 넣고.. 알아서..
    putenv("TDSVER=80");


     $link = mssql_connect('dbserver', 'DB아이디', 'DB비밀번호');
     if(!$link) {
        echo'Could not connect';
     }else{
      echo'Successful connection';

     }
     mssql_close($link);
 ?>


출처 : http://faq.hostway.co.kr/Linux_WEB/1261


'Works > 확장모듈설치매뉴얼' 카테고리의 다른 글

Zend Guard Loader 설치  (0) 2017.05.17
APC 확장모듈 설치  (0) 2017.04.26
mod_mime_magic 설치  (0) 2016.08.01
oAuth 확장모듈 설치  (0) 2016.03.29
CentOS6 에서 mcrypt 확장모듈 설치시의 방법  (0) 2016.02.26


du -sh . --exclude='패턴' (현재 위치에서 '패턴' 파일 또는 폴더를 제외하고 전체 용량을 확인)
du -sh * --exclude='패턴' (현재 위치에서 '패턴' 파일 또는 폴더를 제외한 모든 항목들의 개별 용량 확인)

용량이 1기가바이트 이상인 파일이나 디렉토리만 보고 싶다면 아래처럼 grep을 활용할 수도 있습니다.

du -sh ./* | grep G

'Works > CentOS & RockyLinux' 카테고리의 다른 글

CentOS7 hostname 설정  (0) 2016.10.31
tmpwatch  (0) 2016.10.19
필요한 rpm 패키지를 다운받자  (0) 2016.08.03
xferlog 항목별 분석  (0) 2016.07.27
smartctl을 이용한 하드디스크 진단 { DRDY ERR } 확인  (0) 2016.07.06


/usr/local/apache/bin/apachectl restart 를 이용해 


Apache를 재시작 하려는데 다음과 같은 메시지가 뜨는 경우가 있습니다.

=================================================
(20014)Internal error: Error retrieving pid file logs/httpd.pid
Remove it before continuing if it is corrupted.

=================================================



기존에 구동중인 아파치가 정상 종료 되지 않을 경우 프로세스가 남아 있게 되어 발생되는 부분으로

구동중인 httpd 데몬을 전부 종료하고 다시 시작하시면 되겠습니다.


종료:
killall -9 httpd

구동:
/usr/local/apache/bin/apachectl start

그래도 정상 구동이 되지 않을 시 해당 httpd.pid 파일을 삭제 하신 뒤 재시작하여 보시기 바랍니다.

해당 파일은 구동 시 자동 생성 되는 파일이므로 삭제 후 재시작을 하여도 무방합니다.

출처 : http://faq.hostway.co.kr/Linux_WEB/7565


그누보드 5에서 관리자 또는 일반회원의 패스워드를 모두 올바르게 입력하고 로그인 시도시

팝업창으로 '로그인 하십시오' 가 계속 발생하면 아래의 몇가지를 의심해 봐야한다.

data/session 디렉토리의 퍼미션 확인 (웹서버에 의해 세션이 기록 될수 있는 퍼미션인지)

퍼미션이 올바른 경우 config.php 파일에 문제가 있을 가능성이 있으므로 그누보드5의 초기 config.php 파일로

해당 파일을 대체한다.

(주의 할점은 원본 config.php 파일과 다르게 해당파일 내용을 수정한 경우라면 원본파일에 수정한 값을 동일하게 설정해야함)





yum 으로 찾을 수 없는 rpm 패키지들은 아래 웹사이트에서 검색 후 마우스 우클릭으로 바로가기 복사 후

쉘에서 wget 으로 받은 후 설치하면 된다.

https://www.rpmfind.net (RPM find)

'Works > CentOS & RockyLinux' 카테고리의 다른 글

tmpwatch  (0) 2016.10.19
du 명령어의 활용  (0) 2016.09.02
xferlog 항목별 분석  (0) 2016.07.27
smartctl을 이용한 하드디스크 진단 { DRDY ERR } 확인  (0) 2016.07.06
/bin/rm: Argument list too long  (0) 2016.06.28


[해결] yum install libtool-ltdl-devel



* Incident

 

웹서버에서는 파일을 인식할 때 mime에 등록된 확장자를 참고하여 문서 형식을 결정하고 불러오는데 mime에 등록된 확장자가 아니고 파일의 내용을 통해 자동으로 문서 형식을 결정하는 기능이 필요할 때가 있다. 예를 들면, 아파치 기반의 어떤 사이트의 경우 이미지 파일이 확장자를 사용하지 않도록 개발하는 경우도 있다. 이때 필요한 것이 mod_mime_magic 모듈이다.

 

 

* Resolution

 

- mod_mime_magic 설치


1. 기존 웹서버와 동일한 버전의 아파치 설치파일을 다운로드 후 압축 해제한다.

[root@mooon]# wget https://archive.apache.org/dist/httpd/httpd-2.2.13.tar.gz

[root@mooon]# tar xvfz httpd-2.2.13.tar.gz

[root@mooon]# cd httpd-2.2.13


2. mod_mime_magic.so 파일을 생성한다.

※ 자동으로 /usr/local/apache/modules/ 에 mod_mime_magic.so 파일이 생성되고 httpd.conf 파일에 관련 정보가 추가된다.

[root@mooon]# /usr/local/apache/bin/apxs -i -a -c /root/pkg/httpd-2.2.13/modules/metadata/mod_mime_magic.c


3. 아파치를 재시작 한다.

[root@mooon]# /etc/rc.d/init.d/apachectl configtest

[root@mooon]# /etc/rc.d/init.d/apachectl restart


※ mod_mime_magic 모듈을 적용한 후에도 파일이 정상적으로 열리지 않는 경우가 있다.

이는 FTP에 데이터 전송유형이 자동일 경우 파일업로드 시 확장자가 없는 경우 텍스트파일로 인식하여 아스키(ASCII)모드로 전송된다.

이렇게 전송되는 경우 원본파일과 동일한 데이터가 업로드되지 않고 변조된 데이터가 업로드 됨으로서 파일이 깨지게 된다.

파일질라에서는 [전송 > 전송 유형 > 바이너리]로 변환 후 확장자가 없는 파일을 업로드하면 해결된다.

[출처] http://www.joshi.co.kr/?mid=board_Szhe52&document_srl=1148&order_type=desc&listStyle=viewer&page=3

'Works > 확장모듈설치매뉴얼' 카테고리의 다른 글

APC 확장모듈 설치  (0) 2017.04.26
freetds 확장모듈 설치  (0) 2016.09.27
oAuth 확장모듈 설치  (0) 2016.03.29
CentOS6 에서 mcrypt 확장모듈 설치시의 방법  (0) 2016.02.26
PHP zip 확장모듈 설치  (0) 2016.02.26