2021년 10월 4일 월요일

자동 시작프로그램 설정

 

(1)  설정

* 처음에는 해당 위치에 해당 파일이 없는 경우가 일반적이다.

또한 해당 파일이 /etc/rc.local 위치에 있어야 그 부분을 통과한다.

 

1.    $sudo vim /etc/rc.local

#!/bin/bash

 

sudo -H -u yujin /opt/sword/bin/server/http_server start &

     -H sets the HOME environment variable to that of the user.

     -u specifies the username to run as.

     & : run this program as background.

2.    $sudo chmod[1]  +x /etc/rc.local

 

(2)  Background로 돌아가고 있는 프로그램 확인할 수 있는방법

$ ps -eo uid,pid,ppid,stat,comm | grep ${program_name}

(3)  (예외) 로그인 후 프로그램이 동작하길 원함

1.    로그인 후 실행될 파일 만들기

$sudo vim /etc/profile.d/xxx.sh

#!/bin/bash

 

/opt/sword/scripts/run_script/launcher.sh &

2.    Port확인 ( rest / websocket의 경우 뚫려있는지 확인필요)

$ netstat -nap | grep 8080


+x 모드로 간다는 의미 = 모든 사용자에게 실행권한을 준다는 의미

detail : https://eunguru.tistory.com/93

 

이를 숫자로 표현할 때의 의미 : https://www.maketecheasier.com/file-permissions-what-does-chmod-777-means/


1. 실행파일을 rc.local에 등록시켜서 함께 켜지도록 등록하는 방법

2. daemon으로 등록해서 함께 실행하는 방법