티스토리 뷰
반응형
리눅스 서버 사용 종료 시 특정 스크립트를 실행 하여 /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
- ansible ios
- ansible network
- CentOS 7 GUI
- shell connmad log
- cmd로 계정 생성
- ILO
- oracle linux8 kernel
- ios ansible
- dl20 g9 centos7 설치
- 리눅스 커맨드 로그남기기
- 특정 라인삭제
- ipmi
- ISCSI 볼륨 RAC
- dl20
- vm rac
- cgroup
- 윈도우서버 계정 관려
- nutanix rac
- chrony
- windows.old 강제삭제
- DL20 GEN9 장비에 CentOS 7
- cmd로 윈도우 계정 관리
- kernel 변경
- cisco ansible
- linux command log
- 특정 문구 치환
- nxos ansible
- 윈도우 cmd 계정 관리
- dl20 centos7
- centos7 ntp
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
글 보관함
