-
팰월드 서버 자동 재부팅 설정게임/팰월드 2025. 1. 17. 00:41
깃허브 참고
https://gist.github.com/Insax/37617020076cfad912222f57d3cc270a1. 사전준비
우선 편하게 설정하기 위해 사용중인 리눅스 환경의 시간대를 한국으로 맞춰주어야한다.
sudo timedatectl set-timezone Asia/Seoul
rcon파일을 다운받기 위해 아래 코드를 입력
wget https://github.com/gorcon/rcon-cli/releases/download/v0.10.3/rcon-0.10.3-amd64_linux.tar.gz
이 파일이 tar.gz형식의 압축파일인만큼 이 압축을 풀어주어야한다.
tar -zxvf rcon-0.10.3-amd64_linux.tar.gz
rcon.yaml파일을 수정해준다.(hedo는 본인에 맞게 수정)
nano /home/hedo/rcon-0.10.3-amd64_linux/rcon.yaml
address에 :54655는 자신이 열어놓은 rcon 포트에 맞게 수정을 하고 superSafePassword 부분은 자신이 설정한 어드민 비밀번호로 수정한다.
default: address: "" # host:port, for example 127.0.0.1:16260 password: "" log: "rcon-default.log" type: "" # rcon, telnet, web. timeout: "10s" palworld: address: "127.0.0.1:54655" # host:port, 127.0.0.1 should always work, please adjust to your set rcon port in palworld config password: "superSafePassword" log: "rcon-default.log" type: "rcon" # rcon, telnet, web. timeout: "10s"
ctrl+x, y 엔터로 저장
선택지가 2개로 나뉘는데 팰월드서버 자체 백업을 믿고 리부팅만 하기, 따로 백업해서 외부로 빼내기
2-1.리부팅만 하기
재시작 실행파일을 만들어준다.nano ~/shutdown.sh
내용은 아래에서 복붙하고 hedo를 본인에 맞게 수정#!/bin/bash /usr/local/bin/rcon -c /home/hedo/rcon-0.10.3-amd64_linux/rcon.yaml -e palworld "broadcast Saving_Map_&_Server" /usr/local/bin/rcon -c /home/hedo/rcon-0.10.3-amd64_linux/rcon.yaml -e palworld "save" #Sleep here so we can save no matter the shutdown time. sleep 10 /usr/local/bin/rcon -c /home/hedo/rcon-0.10.3-amd64_linux/rcon.yaml -e palworld "broadcast Initiating_Automated_Shutdown" /usr/local/bin/rcon -c /home/hedo/rcon-0.10.3-amd64_linux/rcon.yaml -e palworld "shutdown 100" #shutdown vps sleep 100 sudo shutdown -r now
서버 재부팅 명령어가 실행되는 시간 설정 (분 시 일 월 요일) (여기서 한대로 복붙하면 새벽 5시에 재부팅 된다)
(여기서도 palworld.service와 같이 hedo를 본인에 맞게 수정해주면 된다)
crontab -e
0 5 * * * sh /home/hedo/shutdown.sh
ctrl+x, y로 저장해주면 된다.
잘 작성되었는지 확인
crontab -l
2-2. 백업하고 리부팅하기
백업 실행파일을 만들어준다.
nano ~/backup.sh
내용은 아래 복붙하고 위에서 계속 나오던거 처럼 hedo를 본인에 맞게 수정
#!/bin/bash TARGET_FOLDER="/home/hedo/Steam/steamapps/common/PalServer/Pal/Saved/SaveGames/" BACKUP_FOLDER="/home/hedo/backups" #Create backup dir in case it does not exist mkdir -p "$BACKUP_FOLDER" # Hourly backups HOUR_FILE="$BACKUP_FOLDER/hourly_$(date +\%H).tar.gz" tar -czf "$HOUR_FILE" "$TARGET_FOLDER" # Keep only last 3 hourly backups ls -tpd $BACKUP_FOLDER/* | grep hourly | tail -n +4 | xargs -I {} rm -- {} # Daily backup at 4am if [ "$(date +\%H)" == "04" ]; then DAY_FILE="$BACKUP_FOLDER/daily_$(date +\%F).tar.gz" cp "$HOUR_FILE" "$DAY_FILE" fi # Weekly backup at Sunday 4am if [ "$(date +\%u)" == "7" ] && [ "$(date +\%H)" == "04" ]; then WEEK_FILE="$BACKUP_FOLDER/weekly_$(date +\%Y-\%V).tar.gz" cp "$DAY_FILE" "$WEEK_FILE" fi
이번엔 셧다운 실행파일을 만들어준다.
nano ~/shutdown.sh
내용은 아래 복붙(항상 말한대로 hedo는 자신에 맞게 수정)
#!/bin/bash /usr/local/bin/rcon -c /home/hedo/rcon-0.10.3-amd64_linux/rcon.yaml -e palworld "broadcast Saving_Map_&_Server" /usr/local/bin/rcon -c /home/hedo/rcon-0.10.3-amd64_linux/rcon.yaml -e palworld "save" #Sleep here so we can save no matter the shutdown time. sleep 10 /usr/local/bin/rcon -c /home/hedo/rcon-0.10.3-amd64_linux/rcon.yaml -e palworld "broadcast Initiating_Automated_Shutdown" /usr/local/bin/rcon -c /home/hedo/rcon-0.10.3-amd64_linux/rcon.yaml -e palworld "shutdown 100" #shutdown vps sleep 10 sudo shutdown -r now
자동실행되도록 crontab에 등록
crontab -e
# 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 5 * * * sh /home/hedo/shutdown.sh 0 * * * * sh /home/hedo/backup.sh
매시 정각에 백업되고 새벽 5시에 재부팅 되도록 설정된거니 본인이 원하는 시간이 있다면 수정
3. 부팅시 팰서버 자동 실행
리눅스가 켜지면 팰월드 서버가 자동으로 실행되도록 해주도록 파일을 만들어준다.
sudo nano /etc/systemd/system/palworld.service
내용은 아래 내용을 복사하고 hedo를 자신에 맞게 수정
[Unit] Description=PalWorld Server After=network.target [Service] WorkingDirectory=/home/hedo/Steam/steamapps/common/PalServer ExecStartPre=/usr/games/steamcmd +login anonymous +app_update 2394010 validate +quit ExecStart=/home/hedo/Steam/steamapps/common/PalServer/PalServer.sh Restart=always User=hedo [Install] WantedBy=multi-user.target
멀티 스레드를 활성화하려면 ExecStart=/home/hedo/Steam/steamapps/common/PalServer/PalServer.sh 뒤에 -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS를 추가해주면 된다.
이렇게 만들어진 palworld.service의 상태를 확인sudo systemctl status palworld.service
이제 자동으로 실행되도록 enable 시켜준다
sudo systemctl enable palworld.service
그후에 바로 실행시키려면
sudo systemctl start palworld
모드 수정등으로 서버를 끌 일이 생긴다면
sudo systemctl stop palworld
반응형