1、背景
ssh连接服务器断开之后启动的项目被默认停掉了。
使用了nohup ./nginx &。setsid等方法还是不行。
后面确定是中间的网关做了处理。会将当前登录的用户启动的进程都会停掉。
2、解决办法
创建新用户,并分配root权限,然后用新用户启动项目。断开ssh后就不会停进程了。
groupadd -g 9631 mygroup
useradd -u 9631 -g mygroup-d /home/myuser myuser
passwd myuser设置密码为XXX
给新用户设置sudo权限:
[root@localhost ~]# sudoers
bash: sudoers: 未找到命令...
[root@localhost ~]# whereis sudoers
sudoers: /etc/sudoers /etc/sudoers.d /usr/libexec/sudoers.so /usr/share/man/man5/sudoers.5.gz
[root@localhost ~]# ls -l /etc/sudoers
-r--r----- 1 root root 4251 9月 25 15:08 /etc/sudoers
[root@localhost ~]# chmod -v u+w /etc/sudoers
mode of "/etc/sudoers" changed from 0440 (r--r-----) to 0640 (rw-r-----)
[root@localhost ~]# vim /etc/sudoers
在文件中找到下面这一行,并添加自己的用户
root ALL=(ALL) ALL
myuser ALL=(ALL) ALL #这个是新增的用户
[root@localhost ~]# chmod -v u-w /etc/sudoers
mode of "/etc/sudoers" changed from 0640 (rw-r-----) to 0440 (r--r-----)
[myuser @localhost ~]$ sudo cat /etc/passwd
Centos7.6非root用户配置JDK和TOMCAT
在centos7.6非root用户下启动tomcat时报错:
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
解决:
在tomcat的/bin/目录下,找到setclasspath.sh
然后sudo vim setclasspath.sh
在图中方框位置追加自己的JAVA_HOME和JRE_HOME
export JAVA_HOME=/usr/local/jdk1.7.0_67
export JRE_HOME=/usr/local/jdk1.7.0_67/jre
最后重新启动tomcat即可。注意,新用户需要有高级权限的话。都需要加上sodo;
sudo bin/startup.sh
或者 source /etc/profile; nohup java -jar XXXX