-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_server_verysync.sh
More file actions
67 lines (49 loc) · 1.18 KB
/
run_server_verysync.sh
File metadata and controls
67 lines (49 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# 唯一需要改的 定义服务名称和命令
server_name=verysync
start_command="$PWD/$server_name"
echo 定义服务名称和命令为:
echo $start_command
echo
#start_command="$PWD/$server_name"
chmod 777 $PWD/$server_name
cat << EOF > /etc/systemd/system/$server_name.service
[Unit]
Description=$server_name
After=network.target
Wants=network.target
[Service]
WorkingDirectory=$PWD
ExecStart=$start_command
Restart=on-failure
StandardOutput=append:$PWD/$server_name.log
StandardError=append:$PWD/$server_name.log
[Install]
WantedBy=multi-user.target
EOF
#重新加载 systemd 配置以识别新的服务文件:
systemctl daemon-reload
systemctl enable $server_name.service
systemctl start $server_name.service
#检查服务
echo 服务为:
cat /etc/systemd/system/$server_name.service
echo
#检查状态并打印
echo 状态为:
sudo systemctl status $server_name.service | tee /dev/tty
systemctl --no-pager status $server_name.service
echo
echo 开启日志轮转
cat << EOF > /etc/logrotate.d/$server_name
$PWD/$server_name.log {
rotate 10
size 10M
copytruncate
missingok
notifempty
compress
delaycompress
create 640 root adm
}
EOF