본문 바로가기
강의 실습/비전공자도 이해할 수 있는 리눅스 입문 실전

[실습] 실행시킨 Spring Boot 프로세스를 조회하고 종료해보기

by jint 2025. 11. 20.

1. 실행시킨 Spring Boot 프로세스를 조회하고 종료해보기
1) Spring Boot 서버 실행
- Ubuntu

ubuntu@ip-172-31-39-75:~$ cd ~
ubuntu@ip-172-31-39-75:~$ ls
all.txt  app.txt  awesome-service  directory.txt  dummy.txt  error.txt  linux-springboot  list.txt  list2.txt  list3.txt  list4.txt  myfile.txt  new-box  result.txt
ubuntu@ip-172-31-39-75:~$ cd linux-springboot
ubuntu@ip-172-31-39-75:~/linux-springboot$ cd build/libs
ubuntu@ip-172-31-39-75:~/linux-springboot/build/libs$ ls
app.log  linux-springboot-0.0.1-SNAPSHOT-plain.jar  linux-springboot-0.0.1-SNAPSHOT.jar
ubuntu@ip-172-31-39-75:~/linux-springboot/build/libs$ java -jar linux-springboot-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.5.0)

2025-11-20T13:12:24.852Z  INFO 368203 --- [linux-springboot] [           main] c.e.l.LinuxSpringbootApplication         : Starting LinuxSpringbootApplication v0.0.1-SNAPSHOT using Java 17.0.16 with PID 368203 (/home/ubuntu/linux-springboot/build/libs/linux-springboot-0.0.1-SNAPSHOT.jar started by ubuntu in /home/ubuntu/linux-springboot/build/libs)
2025-11-20T13:12:24.861Z  INFO 368203 --- [linux-springboot] [           main] c.e.l.LinuxSpringbootApplication         : No active profile set, falling back to 1 default profile: "default"
2025-11-20T13:12:26.928Z  INFO 368203 --- [linux-springboot] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2025-11-20T13:12:26.964Z  INFO 368203 --- [linux-springboot] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2025-11-20T13:12:26.965Z  INFO 368203 --- [linux-springboot] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.41]
2025-11-20T13:12:27.025Z  INFO 368203 --- [linux-springboot] [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2025-11-20T13:12:27.027Z  INFO 368203 --- [linux-springboot] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2002 ms
2025-11-20T13:12:27.707Z  INFO 368203 --- [linux-springboot] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path '/'
2025-11-20T13:12:27.759Z  INFO 368203 --- [linux-springboot] [           main] c.e.l.LinuxSpringbootApplication         : Started LinuxSpringbootApplication in 3.858 seconds (process running for 4.87)


2) 잘 작동하는 지 확인
http://{EC2 인스턴스의 Public IP 주소}:8080 주소로 접속한다.
EC2 인스턴스의 Public IP 주소는 EC2 터미널창 하단의 PublicIPs: 13.xxx.xxx.xxx 부분을 보고 확인할 수 있다.

 

Spring Boot 정상 실행 확인 페이지


Spring Boot 가 잘 실행된 것을 확인할 수 있다.

3) 새로운 터미널 창 열어서 프로세스 조회해보기
Spring Boot 서버를 실행시킨 채로 다른 명령어를 입력하려고 해도 작동하지 않기 때문에 새로운 터미널 창을 연다. 그리고 ps aux 명령어를 입력한다.

- Ubuntu

ubuntu@ip-172-31-39-75:~$ ps aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  1.2  22552 11608 ?        Ss   Aug31   2:20 /usr/lib/systemd/systemd --system --deserialize=76
root           2  0.0  0.0      0     0 ?        S    Aug31   0:01 [kthreadd]
root           3  0.0  0.0      0     0 ?        S    Aug31   0:00 [pool_workqueue_release]
root           4  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-rcu_gp]
root           5  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-sync_wq]
root           6  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-kvfree_rcu_reclaim]
root           7  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-slub_flushwq]
root           8  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-netns]
root          11  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/0:0H-events_highpri]
root          13  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-mm_percpu_wq]
root          14  0.0  0.0      0     0 ?        I    Aug31   0:00 [rcu_tasks_rude_kthread]
root          15  0.0  0.0      0     0 ?        I    Aug31   0:00 [rcu_tasks_trace_kthread]
root          16  0.0  0.0      0     0 ?        S    Aug31   0:04 [ksoftirqd/0]
root          17  0.0  0.0      0     0 ?        I    Aug31   2:02 [rcu_sched]
root          18  0.0  0.0      0     0 ?        S    Aug31   0:00 [rcu_exp_par_gp_kthread_worker/0]
root          19  0.0  0.0      0     0 ?        S    Aug31   0:00 [rcu_exp_gp_kthread_worker]
root          20  0.0  0.0      0     0 ?        S    Aug31   0:40 [migration/0]
root          21  0.0  0.0      0     0 ?        S    Aug31   0:00 [idle_inject/0]
root          22  0.0  0.0      0     0 ?        S    Aug31   0:00 [cpuhp/0]
root          23  0.0  0.0      0     0 ?        S    Aug31   0:00 [cpuhp/1]
root          24  0.0  0.0      0     0 ?        S    Aug31   0:00 [idle_inject/1]
root          25  0.0  0.0      0     0 ?        S    Aug31   0:28 [migration/1]
root          26  0.0  0.0      0     0 ?        S    Aug31   0:04 [ksoftirqd/1]
root          28  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/1:0H-events_highpri]
root          29  0.0  0.0      0     0 ?        S    Aug31   0:00 [kdevtmpfs]
root          30  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-inet_frag_wq]
root          31  0.0  0.0      0     0 ?        S    Aug31   0:00 [kauditd]
root          32  0.0  0.0      0     0 ?        S    Aug31   0:02 [khungtaskd]
root          34  0.0  0.0      0     0 ?        S    Aug31   0:00 [oom_reaper]
root          36  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-writeback]
root          37  0.0  0.0      0     0 ?        S    Aug31   4:42 [kcompactd0]
root          38  0.0  0.0      0     0 ?        SN   Aug31   0:00 [ksmd]
root          39  0.0  0.0      0     0 ?        SN   Aug31   0:00 [khugepaged]
root          40  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-kintegrityd]
root          41  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-kblockd]
root          42  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-blkcg_punt_bio]
root          43  0.0  0.0      0     0 ?        S    Aug31   0:00 [irq/9-acpi]
root          45  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-tpm_dev_wq]
root          46  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-ata_sff]
root          47  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-md]
root          48  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-md_bitmap]
root          49  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-edac-poller]
root          50  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-devfreq_wq]
root          51  0.0  0.0      0     0 ?        S    Aug31   0:00 [watchdogd]
root          52  0.0  0.0      0     0 ?        I<   Aug31   0:03 [kworker/1:1H-kblockd]
root          53  0.0  0.0      0     0 ?        S    Aug31   0:10 [kswapd0]
root          54  0.0  0.0      0     0 ?        S    Aug31   0:00 [ecryptfs-kthread]
root          55  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-kthrotld]
root          56  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-acpi_thermal_pm]
root          57  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-nvme-wq]
root          58  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-nvme-reset-wq]
root          59  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-nvme-delete-wq]
root          60  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-nvme-auth-wq]
root          62  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-mld]
root          63  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-ipv6_addrconf]
root          70  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-kstrp]
root          72  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/u9:0]
root          85  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-charger_manager]
root          86  0.0  0.0      0     0 ?        S    Aug31   0:13 [jbd2/nvme0n1p1-8]
root          87  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-ext4-rsv-conversion]
root          88  0.0  0.0      0     0 ?        I<   Aug31   0:03 [kworker/0:1H-kblockd]
root         164  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-kmpathd]
root         165  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-kmpath_handlerd]
root         251  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-ena]
root         254  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-cryptd]
root         289  0.0  0.0      0     0 ?        S    Aug31   0:00 [jbd2/nvme0n1p16-8]
root         290  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-ext4-rsv-conversion]
message+     604  0.0  0.3  10040  3596 ?        Ss   Aug31   1:03 @dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root         612  0.0  1.4  32424 13108 ?        Ss   Aug31   0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root         621  0.0  0.5  18168  5612 ?        Ss   Aug31   0:13 /usr/lib/systemd/systemd-logind
root         704  0.0  0.0   6148   476 ttyS0    Ss+  Aug31   0:00 /sbin/agetty -o -p -- \u --keep-baud 115200,57600,38400,9600 - vt220
root         726  0.0  1.1 110020 10888 ?        Ssl  Aug31   0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
root         805  0.0  0.0   6104   464 tty1     Ss+  Aug31   0:00 /sbin/agetty -o -p -- \u --noclear - linux
root         995  0.0  1.5 1830624 14832 ?       Ssl  Aug31   3:07 /snap/amazon-ssm-agent/11797/amazon-ssm-agent
root        1599  0.0  0.0      0     0 ?        I<   Aug31   0:00 [kworker/R-tls-strp]
root       82824  0.0  0.2   2720  1996 ?        Ss   Sep23   0:00 /usr/sbin/acpid
root       82827  0.0  0.4  82920  3792 ?        Ssl  Sep23   2:05 /usr/sbin/irqbalance
_chrony    82844  0.0  0.3  19400  3560 ?        S    Sep23   1:23 /usr/sbin/chronyd -F 1
_chrony    82845  0.0  0.2  11072  2236 ?        S    Sep23   0:00 /usr/sbin/chronyd -F 1
root       82854  0.0  2.8 288952 27088 ?        SLsl Sep23   7:31 /sbin/multipathd -d -s
polkitd    82891  0.0  0.8 383536  8212 ?        Ssl  Sep23   1:37 /usr/lib/polkit-1/polkitd --no-debug
root       82909  0.0  0.8 391876  7508 ?        Ssl  Sep23   0:00 /usr/sbin/ModemManager
syslog     82911  0.0  0.6 222508  5680 ?        Ssl  Sep23   0:12 /usr/sbin/rsyslogd -n -iNONE
root       83277  0.0  0.2   7224  2308 ?        Ss   Sep23   0:13 /usr/sbin/cron -f -P
root      131610  0.0  1.7  66844 16424 ?        S<s  Oct02   0:58 /usr/lib/systemd/systemd-journald
systemd+  131612  0.0  0.7  21580  6936 ?        Ss   Oct02   0:06 /usr/lib/systemd/systemd-resolved
root      131618  0.0  0.4  12020  4660 ?        Ss   Oct02   0:25 sshd: /usr/sbin/sshd -D -o AuthorizedKeysCommand /usr/share/ec2-instance-connect/eic_run_authorized_keys %u %f -o AuthorizedKeysCommandUser ec2-
root      131626  0.0  0.6  26488  5784 ?        Ss   Oct02   0:03 /usr/lib/systemd/systemd-udevd
root      131627  0.0  0.9 469088  9088 ?        Ssl  Oct02   1:24 /usr/libexec/udisks2/udisksd
root      131641  0.0  0.0      0     0 ?        S    Oct02   0:00 [psimon]
systemd+  131642  0.0  0.6  19000  6348 ?        Ss   Oct02   0:05 /usr/lib/systemd/systemd-networkd
root      223508  0.0  2.8 1923800 27092 ?       Ssl  Oct22   1:23 /usr/lib/snapd/snapd
root      367494  0.0  0.0      0     0 ?        I    10:30   0:00 [kworker/1:0-events]
root      367633  0.0  0.0      0     0 ?        I    12:05   0:00 [kworker/u8:1-events_power_efficient]
root      367634  0.0  0.0      0     0 ?        I    12:05   0:00 [kworker/u8:3-events_power_efficient]
root      367735  0.0  1.1  14708 10504 ?        Ss   13:08   0:00 sshd: ubuntu [priv]
root      368036  0.0  0.0      0     0 ?        S    13:08   0:00 [psimon]
ubuntu    368038  0.0  1.2  20272 11444 ?        Ss   13:08   0:00 /usr/lib/systemd/systemd --user
root      368039  0.0  0.0      0     0 ?        I    13:08   0:00 [kworker/0:0]
root      368040  0.0  0.0      0     0 ?        I    13:08   0:00 [kworker/0:3-events]
ubuntu    368041  0.0  0.3  21148  3528 ?        S    13:08   0:00 (sd-pam)
ubuntu    368150  0.0  0.7  14972  7020 ?        S    13:08   0:00 sshd: ubuntu@pts/0
ubuntu    368153  0.0  0.5   9320  5540 pts/0    Ss   13:08   0:00 -bash
root      368193  0.0  0.0      0     0 ?        I    13:09   0:00 [kworker/u8:0-events_power_efficient]
ubuntu    368203  1.1 15.3 2785484 143964 pts/0  Sl+  13:12   0:11 java -jar linux-springboot-0.0.1-SNAPSHOT.jar
root      368266  0.0  0.0      0     0 ?        I    13:20   0:00 [kworker/1:3-cgroup_destroy]
root      368271  0.0  0.0      0     0 ?        I    13:24   0:00 [kworker/u8:2-events_unbound]
root      368285  0.0  1.1  14708 10520 ?        Ss   13:28   0:00 sshd: ubuntu [priv]
ubuntu    368640  0.0  0.7  14964  6892 ?        S    13:28   0:00 sshd: ubuntu@pts/1
ubuntu    368641  0.0  0.5   9056  5420 pts/1    Ss   13:28   0:00 -bash
ubuntu    368651  0.0  0.4  11320  4392 pts/1    R+   13:28   0:00 ps aux


출력값을 살펴보면 익숙한 명령어(java -jar linux-springboot-0.0.1-SNAPSHOT.jar)가 보인다. 프로세스 실행시 사용한 명령어가 출력되었다. 이 프로세스가 Spring Boot 의 프로세스 이다.
하지만 실행 중인 프로세스를 일일이 찾기 힘들다. 실무에서는 | grep 을 사용하여 실행중인 프로세스를 빠르게 찾는다.

- Ubuntu

ubuntu@ip-172-31-39-75:~$ ps aux | grep java
ubuntu    368203  1.0 15.3 2785484 143964 pts/0  Sl+  13:12   0:11 java -jar linux-springboot-0.0.1-SNAPSHOT.jar
ubuntu    368658  0.0  0.2   7076  2108 pts/1    S+   13:31   0:00 grep --color=auto java


Spring Boot 서버 실행 후 프로세스가 죽지 않고 정상적으로 잘 실행됐는지 확인할 때도 종종 사용한다.

4) Spring Boot 프로세스 종료하기
실행 중인 Spring Boot 서버를 종료하려면, 실행 중인 Spring Boot 프로세스의 PID 를 알아야 한다. ps aux | grep java 명령어를 통해 368203 이라는 것을 확인했다.
PID 를 활용해 프로세스 종료 명령어를 실행한다.

- Ubuntu

ubuntu@ip-172-31-39-75:~$ kill 368203


5) 정상적으로 종료됐는 지 확인하기
#1 Spring Boot 서버를 실행시킨 터미널 창 확인하기
- Ubuntu

2025-11-20T13:41:43.411Z  INFO 368203 --- [linux-springboot] [ionShutdownHook] o.s.b.w.e.tomcat.GracefulShutdown        : Commencing graceful shutdown. Waiting for active requests to complete
2025-11-20T13:41:43.426Z  INFO 368203 --- [linux-springboot] [tomcat-shutdown] o.s.b.w.e.tomcat.GracefulShutdown        : Graceful shutdown complete


#2 IP 주소로 접속해보기
http://{EC2 인스턴스의 Public IP 주소}:8080 주소 접속시, 접속이 되지 않는 것을 확인할 수 있다.

 

IP 주소로 접속시, 접속되지 않음


#3 프로세스 조회해보기
- Ubuntu

ubuntu@ip-172-31-39-75:~$ ps aux | grep java
ubuntu    368717  0.0  0.2   7076  2204 pts/1    S+   13:46   0:00 grep --color=auto java


Spring Boot 프로세스가 없는 것을 확인할 수 있다.


참고링크 : https://www.inflearn.com/course/%EB%B9%84%EC%A0%84%EA%B3%B5%EC%9E%90%EB%8F%84-%EC%9D%B4%ED%95%B4%ED%95%A0-%EC%88%98-%EC%9E%88%EB%8A%94-%EB%A6%AC%EB%88%85%EC%8A%A4-%EC%9E%85

 

비전공자도 이해할 수 있는 리눅스 입문/실전| JSCODE 박재성 - 인프런 강의

현재 평점 5.0점 수강생 291명인 강의를 만나보세요. 비전공자 입장에서도 쉽게 이해할 수 있고, 실전에서 바로 적용 가능한 '리눅스 입문' 강의를 만들어봤습니다! 리눅스를 처음 배우시는 분, Per

www.inflearn.com

댓글