프로세스 이름에 특정 문자열을 가진 프로세스
pkill -f 'PATTERN' 참고 자료 https://unix.stackexchange.com/questions/316065/how-to-kill-all-process-with-given-name
pkill -f 'PATTERN' 참고 자료 https://unix.stackexchange.com/questions/316065/how-to-kill-all-process-with-given-name
lsof -i :포트번호 참고 자료 https://sas-study.tistory.com/281
문법 [ {parameter} {FILE 경로} ] parameter -e: 파일이 존재하면 true 리턴 -f: regular file이 존재하면 true 리턴 -r: 읽기 권한이 있는 파일이 존재하면 true 리턴 -w: 쓰기 권한이 있는 파일이 존재하면 true 리턴 -x: 실행 권한이 있는 파일이 존재하면 true 리턴 -d: 디렉토리가 존재하면 true 리턴 예시 FILE="$1" if [ -f "$FILE" ]; then echo "File $FILE exist." else echo "File $FILE does not exist" >&2 fi 참고 자료 https://www....
윈도우 환경에서는 파일 마지막 줄에 ^M 가 추가되어서 UNIX 환경과 달라 에러가 발생할 수 있다. 이를 해결하기 위해서는 vi로 열어서 :set fileformat=unix 위와 같이 입력하고 파일을 닫으면 된다. 참고 자료 https://stackoverflow.com/questions/2920416/configure-bin-shm-bad-interpreter
배경 용량이 큰 로그 파일을 vim이나 cat으로 열게 된다면, 파일 내용을 RAM에 모두 올리면서 OOM 에러가 발생할 수 있다. less less [파일명] 이 명령어를 통해 파일을 열면 내용을 청크로 잘라서 조금씩 볼 수 있기 때문에 OOM이 발생하지 않는다. 참고 자료 https://jmseo.tistory.com/69
매번 ip를 입력하기엔 너무 불편하다. vi /etc/hosts [서비스용IP] [별칭]
ssh-keygen 이라는 명령어를 통해서 생성할 수 있다. ssh-keygen 위와 같이 아무를 옵션없이 키 쌍을 생성하면, ~/.ssh/id_rsa.pub 라는 파일에 생성된다. -t 옵셩능 사용하여 알고리즘과 크의 크기를 지정할 수도 있다. ssh-keygen -t rsa -b 4096 해당 키를 사용할 서버의 ~/.ssh/authorized_keys에 퍼블릭 키를 추가하면 된다. 참고 자료 https://m.blog.naver.com/sehyunfa/221737099486
Redirection은 (>의 경우) 왼쪽 프로그램의 출력을 오른쪽으로 지정한다. 파일 등으로 지정할 수 있다. pipe는 왼쪽 프로그램의 output을 오른쪽 프로그램의 input으로 사용한다.
scp -i [pem파일경로] [업로드할 파일 이름] [계정명]@[ip 주소]:~/[경로] https://ict-nroo.tistory.com/40
발생한 문제 logrotate 명령어 수행시 error: Ignoring {config 파일 경로} because the file owner is wrong (should be root or user with uid 0). 가 발생함 이전 서버 환경에서는 이런 문제가 없었는데 신규 서버에서 발생함 원인 logrotate 3.8.0 부터 root 권한으로 logrotate 실행 시, config 파일의 파일 소유자가 root 인지 검증한다. 이전 서버에서는 3.8.0 보다 낮은 버전이어서 문제가 되지 않았다. https://github.com/logrotate/logrotate/blob/master/ChangeLog.md https://github.com/logrotate/logrotate/compare/r3-7-9...r3-8-0 참고 자료 https://superuser.com/questions/793013/logrotate-no-longer-reads-symlinked-configuration-file-due-to-non-root-ownership
목적 Linux에 존재하는 로그 로테이팅 명령어다. logrotate 는 로그 로테이트 과정을 관리하는데 사용되고, cron을 통해서 보통 실행한다. logrotate 실행에 필요한 파일 /usr/sbin/logrotate: logrotate 명령어(실행 파일) /etc/cron.daily/logrotate: anacron을 이용해 매일 실행할 logrotate /etc/logrotate.conf: 로그 로테이트 설정 파일 conf 파일 아래와 같이 로테이트 할 로그 파일 경로와 설정을 명시한다. 정규식을 이용한 표현도 가능하다. /var/log/mail.info /var/log/mail.warn /var/log/mail.err /var/log/mail.log /var/log/daemon.log /var/log/kern.log /var/log/auth.log /var/log/user.log /var/log/lpr.log /var/log/cron.log /var/log/debug /var/log/messages { rotate 4 weekly missingok notifempty compress delaycompress sharedscripts postrotate invoke-rc....
cron 목적 미리 정해진 시간에 예약된 작업 실행을 자동화하는 도구. 백그라운드 프로세스로 실행되며 사용자의 개입 없이 특정 이벤트나 조건이 트리거될 떄 미리 정의된 시간에 지정된 작업을 수행하는 데몬 프로세스다. cron [-f] [-l] [-L loglevel] crontab cron이 실행할 작업을 나열한 파일 실행할 작업을 추가, 제거, 수정이 가능하다. crontab의 커맨드는 공백단위로 분리되며, 순서대로 나음을 의미한다. Minute (holds a value between 0-59) Hour (holds value between 0-23) Day of Month (holds value between 1-31) Month of the year (holds a value between 1-12 or Jan-Dec, the first three letters of the month’s name shall be used) Day of the week (holds a value between 0-6 or Sun-Sat, here also first three letters of the day shall be used) Command 예시 30 08 10 06 * /home/maverick/full-backup anacron 일, 주, 월 빈도로 작업을 실행할 수 있는 명령어 cron 보다 좋은 점: cron은 예약된 시간에 컴퓨터가 꺼져있으면 실행하지 않지만, anacron은 마지막 작업 시각을 확인해서 마지막 실행 시각을 비교해서 시간이 지났으면 실행한다....