서버가 죽어버렸다
계엄령을 내렸나? 싶은 아침
자바는 heap memory가 부족하다며 절규하다가 그대로 사망했다.
뭐 원인과 결과는 너무 명백하지만 시간이 없는 관계로 임시방편인 crontab에 쉘스크립트를 등록시켜
pm2에 해당 프로세스를 야심한 새벽시간대에 reload 명령을 넣기로했다
우선 실행시킬 쉘스크립트를 만들자
touch pm2reload.sh
---pm2reload.sh---
pm2 reload myapi
경로는 ec2환경의 우분투라면 /home/ubuntu/pm2reload.sh 가 될것이다
crontab -e 명령어를 치면
Select an editor. To change later, run 'select-editor'.
1. /bin/nano <---- easiest
2. /usr/bin/vim.basic
3. /usr/bin/vim.tiny
4. /bin/ed
위와 같은 명령어가 나온다 어떤 편집기를 쓸꺼냐라고 묻는것인데 나는 개틀딲개발자니까 vim.basic을 쓸것이다
2를 입력하고 엔터를 치면
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
위와 같은 편집기에 내용이 열린다
0 18 * * * sh /home/ubuntu/pm2reload.sh
위 내용을 추가한 다음 저장하고
crontab -l을 치면 내가 등록한 크론탭 명령어가 보인다
제대로 보인다면 profit이고 없다면 무언가 잘못되거니까 다시 한번 차근차근해보자
사실 자바 탭에 쓸까 말까 고민하다가 귀찮아서 자바탭에 씀
'개발 > java' 카테고리의 다른 글
queryDsl의 Q클래스 객체 사용하기 (1) | 2024.12.02 |
---|---|
404 Not Found으로 전력투구 (1) | 2024.03.26 |
JPA QUERYDSL의 LIKE 구현 (0) | 2024.03.22 |
java 탭을 신설했다. (0) | 2023.06.01 |