pid로 실행 및 종료하는 스크립트 만들기
2025. 3. 27. 19:33ㆍOS
실행
#!/bin/bash
# Run your application in the background and save the PID
your_app_command &
# Save the PID to a file
echo $! > app.pid
echo "Application started with PID $(cat app.pid)"
종료
#!/bin/bash
# Check if the pid file exists
if [ -f app.pid ]; then
PID=$(cat app.pid)
# Kill the process
kill $PID
# Optionally remove the pid file
rm app.pid
echo "Application with PID $PID stopped."
else
echo "PID file not found. Application may not be running."
fi
'OS' 카테고리의 다른 글
Ubuntu 먹통될때 조치 (0) | 2025.04.02 |
---|---|
Ubuntu 먹통되는 문제 조치 (1) | 2025.03.30 |
Ubuntu dns cache 삭제 (0) | 2025.03.21 |
Ubuntu dns 설정 (0) | 2025.03.04 |
Ubunbu에 chrome 설치하기 (0) | 2025.03.03 |