티스토리 뷰
반응형
리눅스 서버 사용 종료 시 특정 스크립트를 실행 하여 /root/shutdown_$(date +"%Y%m%d-%H-%M-%S").txt 파일 생성
다양한 용도의 스크립트를 서버 셧다운 시 응용 가능
- Test os : centos 7
- scripts : /usr/local/sbin/uploadLogsOnShutdown.sh
- systemd 서비스 파일 생성 : vi /etc/systemd/system/uploadLogsOnShutdown.service
uploadLogsOnShutdown.service 내용
[Unit]
Description=upload log files at shutdown
DefaultDependencies=no
Before=shutdown.target halt.target
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/uploadLogsOnShutdown.sh
[Install]
WantedBy=halt.target shutdown.target
- uploadLogsOnShutdown.sh 스크립트 생성 : vi /usr/local/sbin/uploadLogsOnShutdown.sh
uploadLogsOnShutdown.sh 내용
#!/bin/bash
touch /root/shutdown_$(date +"%Y%m%d-%H-%M-%S").txt
- 스크립트 실행 권한 변경
chmod 755 /usr/local/sbin/uploadLogsOnShutdown.sh
- uploadLogsOnShutdown.service systemd 등록
systemctl enable uploadLogsOnShutdown.service
반응형
'linux' 카테고리의 다른 글
acl to glusterfs (0) | 2021.10.29 |
---|---|
install glusterfs on centos7 (0) | 2021.10.28 |
부팅시 프로세스 우선 순위 설정 (Centos 7) (0) | 2021.10.26 |
날짜 이름의 파일 생성하는 방법 (0) | 2021.10.21 |
Allow domain group ssh access & sudoers set (0) | 2021.10.15 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- nxos ansible
- nutanix rac
- shell connmad log
- windows.old 강제삭제
- DL20 GEN9 장비에 CentOS 7
- cgroup
- dl20
- dl20 g9 centos7 설치
- vm rac
- ios ansible
- oracle linux8 kernel
- centos7 ntp
- ISCSI 볼륨 RAC
- CentOS 7 GUI
- dl20 centos7
- 특정 라인삭제
- ansible network
- linux command log
- cisco ansible
- chrony
- ILO
- 윈도우서버 계정 관려
- cmd로 계정 생성
- kernel 변경
- 윈도우 cmd 계정 관리
- 리눅스 커맨드 로그남기기
- cmd로 윈도우 계정 관리
- ansible ios
- 특정 문구 치환
- ipmi
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함