Spring Boot Admin Server, Client config 설정하기

이미지
 Spring Boot로 많은 프로젝트를 진행하게 됩니다. 많은 모니터링 도구가 있지만, Spring Boot 어플리케이션을 쉽게 모니터링 할 수 있는 방법을 소개하려고 합니다.   코드 중심으로 살펴보겠습니다. 1. 어드민 서버 구축 1-1. 디펜던시 추가 dependencies { // https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-server implementation 'de.codecentric:spring-boot-admin-starter-server:2.5.4' } 1-2. 어드민 서버 설정 활성화 @SpringBootApplication @EnableAdminServer public class ServerApplication { public static void main (String[] args) { SpringApplication. run (ServerApplication. class, args) ; } } EnableAdminServer를 하면 됩니다. 2. 클라이언트 서버 설정  예제는 book-client, member-client 2가지 클라이언트, member-client가 2개의 인스턴스 실행으로 작성했습니다.  2-1 디펜던시 추가 dependencies { // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web implementation 'org.springframework.boot:spring-boot-starter-web:2.5.4' // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-actuator implementation 'org.spring...

crontab 시간 설정 방법

 crontab나 jenkins에서 주기적으로 실행해야 할 때가 많이 있습니다. 예를 들어 매일 랭킹을 추출하는 경우가 있습니다. 

jenkins build periodically schedule

시간 설정 방법을 예제를 통해 알아보겠습니다. 


기본 명령어

crontab -l # 등록된 목록 출력
crontab -e # 수정
crontab -r # 삭제


등록 예제

5 * * * * /directory/exe_file.sh


시간 요소

시간 설정은 5가지 요소로 이루어져있습니다.

* * * * *

분(0-59), 시간(0-24), 날(1-31), 월(1-12), 요일(0-6) 0은 일요일
위의 예제는 1분 마다 실행


시간 예제

0 * * * *

0분에 1시간마다 실행
-> 00시00분, 01시00분, 02시00분...


*/5 * * * *

/로 나눠서 실행 주기를 설정할 수 있습니다.
5분마다 실행
-> 00시00분, 00시05분, 00시10분...  


0 3 * * *

매일 3시에 실행 
-> 5월10일 03시00분, 5월11일 03시00분, 5월12일 03시00분...


* 9-18 * * *

-를 사용하여 범위를 지정할 수 있습니다.
매일 9-18시 사이에 1분마다 실행
-> 09시00분, 09시01분, 09시00분, ... 18시58분, 18시59분, ... 다음날 09시00분,...


30 9-18/2 * * *

매일 9-18시 사이에 30분에 2시간마다 실행
-> 09시30분, 11시30분, 13시30분...


30 9,18 * * *

,를 사용하여 필요한 숫자를 지정할 수 있습니다.
매일 9시30분, 18시30분에 실행


0 1 1 * *

매달 1일 1시00분 마다 실행
-> 9월1일 01시0분, 10월1일1시01분, 11월1일1시01분...


10 3 * * 6

매주 토요일 3시10분에 실행
-> 2022년9월10일 03시10분, 2022년9월17일 03시10분, 2022년9월24일 03시10분...


참고로 젠킨스에서는 분설정 부분에 H 를 사용하여 젠킨스에 실행되는 분을 위임할 수 있습니다.

H/5 * * * *

5분마다 실행되지만 0, 5, 10이 아니라, 1,6,11 등 젠킨스의 환경에 맞게 실행


댓글

이 블로그의 인기 게시물

Spring boot redis cache config

Spring boot redis RedisTemplate

MySQL PK 중복 (duplicate key ) 해결 방법