Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何设置开机启动 #27

Open
zsanjin-p opened this issue Apr 17, 2023 · 1 comment
Open

请问如何设置开机启动 #27

zsanjin-p opened this issue Apr 17, 2023 · 1 comment

Comments

@zsanjin-p
Copy link

我试了2种开机方式都不行,文件在/root/cns下

[Unit]
Description=CNS Service
After=network.target

[Service]
Type=simple
ExecStart=/root/cns/cns -daemon
Restart=always
User=root

[Install]
WantedBy=multi-user.target

#!/bin/sh

chkconfig: 345 99 10

description: cns daemon

processname: cns

pidfile: /var/run/cns.pid

configfile: /root/cns/config.cfg

Source function library.

. /etc/rc.d/init.d/functions

prog=cns
lockfile=/var/lock/subsys/$prog
pidfile=/var/run/$prog.pid
configfile=/root/cns/config.cfg
start() {
echo -n $"Starting $prog: "
daemon --pidfile=$pidfile --user=root --check $prog
$prog -f $configfile &
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $lockfile
echo
return $RETVAL
}

stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile
echo
return $RETVAL
}

restart() {
stop
start
}

See how we were called.

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $prog {start|stop|restart}"
exit 1
esac

exit $RETVAL

@rhy12345
Copy link

rhy12345 commented Dec 9, 2023

使用systemctl enable cns就行 程序安装的时候添加了自启程序

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants