powershell 에서 파일 내용 치환하기 > $[변수명] = Get-Content [작업대상파일] | %{$_ -replace('[기존내용]','[변경내용]')}> $[변수명] > [신규대상파일] ex)> $admin = Get-Content c:\admin.cfg | %{$_ -replace('abcd','xyz')}> $admin > c:\test.cfg 개발/Window 2020. 6. 4. 17:44
powershell 에서 파일 인코딩 바꾸기 > Get-Content [기존파일] | Set-Content -Encoding [변경할 언어셋] [신규파일] ex) Get-Content C:\test.cfg | Set-Content -Encoding utf-8 C:\new.cfg cf. 커맨드(cmd)창에서 실행하기- 파워쉘에서는 일반 커맨드창의 bat 파일을 실행할 수 없음.ps1 파일로 저장해준 다음 command 에서 아래의 명령어로 실행 > Powershell.exe -noprofile -executionpolicy bypass -file "[파워셸파일].ps1" 개발/Window 2020. 6. 4. 14:37
rsync를 통한 원격지 백업 1. 원격지에서 백업 # tar zcvf - [백업할 디렉터리] | ssh [원격지서버] "cat > [백업할위치]/[파일이름].tar.gz" # tar zcvf - /home | ssh root@x.x.x.x "cat > /backup/home.tar.gz" 2. 특정디렉터리 제외하여 백업 # tar zcvf - [백업할 디렉터리] --exclude=[백업 제외할 디렉터리] | ssh [원격지서버] "cat > [백업할위치]/[파일이름].tar.gz" # tar zcvfp - /home --exclude=/home/test | ssh root@x.x.x.x "cat > /backup/home.tar.gz" 서버 & 시스템/Linux 2020. 3. 17. 11:32
log가 쌓이지 않을 경우 ** 에러발생 ** 각 서비스의 log 들이 쌓이고 있지 않은 상태 ** 해결방법 ** # systemctl start rsyslog # ps -ef |grep ryslog root 25402 25041 0 18:39 pts/0 00:00:00 grep --color=auto rsys # ps -ef |grep rsyslogroot 25413 1 0 18:39 ? 00:00:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5root 25419 25041 0 18:39 pts/0 00:00:00 grep --color=auto rsys 오류 발생 및 해결 2020. 2. 18. 14:24