service exits after ssh disconnect
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
The service works perfectely if I am not logged in, but if I connect with ssh and then disconnect the service gets terminated. The service belongs to the user to whom I ssh. This is my current ts3.service file:
[Unit]
Description=TeamSpeak3Server
[Service]
User=user1
Group=staff
Type=forking
WorkingDirectory=/usr/local/bin/teamspeak3-server_linux_amd64
ExecStart=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
ExecStop=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh stop
PIDFile=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server.pid
RestartSec=5
Restart=always
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
I have already tried changeing ExecStart to
ExecStart=/usr/bin/nohup /usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
Other services like openvpn survive the ssh logout.
After reconnection the status of the systemd process reads:
active (exited)
while the normal status is
active (running)
Could the cause of the problem be that the script which I execute calls another script which gets killed if the shell sends sighup meassages?
Thank you for your answers.
Edit:
the important part of ts3server_startscript.sh are as follows:
COMMANDLINE_PARAMETERS="$2"
D1=$(readlink -f "$0")
BINARYPATH="$(dirname "$D1")"
cd "$BINARYPATH"
LIBRARYPATH="$(pwd)"
BINARYNAME="ts3server"
if [ -e "$BINARYNAME" ]; then
if[ -x "$BINARYNAME" ]; then
export LD_LIBRARY_PATH="$LIBRARYPATH:$LD_LIBARY_PATH"
"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
PID=$!
ps -p $PID > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "..."
else
echo $PID > ts3server.pid
fi
So if I interpret that correctely the server is started in the console by
"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
debian ssh systemd teamspeak
 |Â
show 7 more comments
up vote
0
down vote
favorite
The service works perfectely if I am not logged in, but if I connect with ssh and then disconnect the service gets terminated. The service belongs to the user to whom I ssh. This is my current ts3.service file:
[Unit]
Description=TeamSpeak3Server
[Service]
User=user1
Group=staff
Type=forking
WorkingDirectory=/usr/local/bin/teamspeak3-server_linux_amd64
ExecStart=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
ExecStop=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh stop
PIDFile=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server.pid
RestartSec=5
Restart=always
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
I have already tried changeing ExecStart to
ExecStart=/usr/bin/nohup /usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
Other services like openvpn survive the ssh logout.
After reconnection the status of the systemd process reads:
active (exited)
while the normal status is
active (running)
Could the cause of the problem be that the script which I execute calls another script which gets killed if the shell sends sighup meassages?
Thank you for your answers.
Edit:
the important part of ts3server_startscript.sh are as follows:
COMMANDLINE_PARAMETERS="$2"
D1=$(readlink -f "$0")
BINARYPATH="$(dirname "$D1")"
cd "$BINARYPATH"
LIBRARYPATH="$(pwd)"
BINARYNAME="ts3server"
if [ -e "$BINARYNAME" ]; then
if[ -x "$BINARYNAME" ]; then
export LD_LIBRARY_PATH="$LIBRARYPATH:$LD_LIBARY_PATH"
"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
PID=$!
ps -p $PID > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "..."
else
echo $PID > ts3server.pid
fi
So if I interpret that correctely the server is started in the console by
"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
debian ssh systemd teamspeak
1
Welcome to Unix Stackexchange! You can take the tour first and the learn How to Ask a good question. That makes it easier for us to help you.
â andcoz
Jun 14 at 14:59
Is there any command in your interactive session that uses the service? Give us some pointer on the other script you are talking about.
â andcoz
Jun 14 at 15:02
Sorry, I'm not sure what you mean by "command in your interactive session thet uses the service". Do you want to know if I'm modifying the service while beeing logged in with ssh? To provocate a crash the only thing requiered is to login via ssh and then kill the session with "exit".
â Beny Benz
Jun 14 at 16:26
1
Instead of"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
try"nohup ./$BINARYNAME" $COMMANDLINE_PARAMETERS < /dev/null > /dev/null 2>&1 &
. See also the good answers at "Best way to make a shell script daemon" on Stack Overflow.
â AlexP
Jun 14 at 16:39
1
Please add the result of runninggrep 'KillUser' /etc/systemd/logind.conf
to your question, and
â roaima
Jun 15 at 8:36
 |Â
show 7 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
The service works perfectely if I am not logged in, but if I connect with ssh and then disconnect the service gets terminated. The service belongs to the user to whom I ssh. This is my current ts3.service file:
[Unit]
Description=TeamSpeak3Server
[Service]
User=user1
Group=staff
Type=forking
WorkingDirectory=/usr/local/bin/teamspeak3-server_linux_amd64
ExecStart=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
ExecStop=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh stop
PIDFile=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server.pid
RestartSec=5
Restart=always
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
I have already tried changeing ExecStart to
ExecStart=/usr/bin/nohup /usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
Other services like openvpn survive the ssh logout.
After reconnection the status of the systemd process reads:
active (exited)
while the normal status is
active (running)
Could the cause of the problem be that the script which I execute calls another script which gets killed if the shell sends sighup meassages?
Thank you for your answers.
Edit:
the important part of ts3server_startscript.sh are as follows:
COMMANDLINE_PARAMETERS="$2"
D1=$(readlink -f "$0")
BINARYPATH="$(dirname "$D1")"
cd "$BINARYPATH"
LIBRARYPATH="$(pwd)"
BINARYNAME="ts3server"
if [ -e "$BINARYNAME" ]; then
if[ -x "$BINARYNAME" ]; then
export LD_LIBRARY_PATH="$LIBRARYPATH:$LD_LIBARY_PATH"
"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
PID=$!
ps -p $PID > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "..."
else
echo $PID > ts3server.pid
fi
So if I interpret that correctely the server is started in the console by
"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
debian ssh systemd teamspeak
The service works perfectely if I am not logged in, but if I connect with ssh and then disconnect the service gets terminated. The service belongs to the user to whom I ssh. This is my current ts3.service file:
[Unit]
Description=TeamSpeak3Server
[Service]
User=user1
Group=staff
Type=forking
WorkingDirectory=/usr/local/bin/teamspeak3-server_linux_amd64
ExecStart=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
ExecStop=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh stop
PIDFile=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server.pid
RestartSec=5
Restart=always
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
I have already tried changeing ExecStart to
ExecStart=/usr/bin/nohup /usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
Other services like openvpn survive the ssh logout.
After reconnection the status of the systemd process reads:
active (exited)
while the normal status is
active (running)
Could the cause of the problem be that the script which I execute calls another script which gets killed if the shell sends sighup meassages?
Thank you for your answers.
Edit:
the important part of ts3server_startscript.sh are as follows:
COMMANDLINE_PARAMETERS="$2"
D1=$(readlink -f "$0")
BINARYPATH="$(dirname "$D1")"
cd "$BINARYPATH"
LIBRARYPATH="$(pwd)"
BINARYNAME="ts3server"
if [ -e "$BINARYNAME" ]; then
if[ -x "$BINARYNAME" ]; then
export LD_LIBRARY_PATH="$LIBRARYPATH:$LD_LIBARY_PATH"
"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
PID=$!
ps -p $PID > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "..."
else
echo $PID > ts3server.pid
fi
So if I interpret that correctely the server is started in the console by
"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
debian ssh systemd teamspeak
edited Jun 14 at 17:16
asked Jun 14 at 13:39
Beny Benz
213
213
1
Welcome to Unix Stackexchange! You can take the tour first and the learn How to Ask a good question. That makes it easier for us to help you.
â andcoz
Jun 14 at 14:59
Is there any command in your interactive session that uses the service? Give us some pointer on the other script you are talking about.
â andcoz
Jun 14 at 15:02
Sorry, I'm not sure what you mean by "command in your interactive session thet uses the service". Do you want to know if I'm modifying the service while beeing logged in with ssh? To provocate a crash the only thing requiered is to login via ssh and then kill the session with "exit".
â Beny Benz
Jun 14 at 16:26
1
Instead of"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
try"nohup ./$BINARYNAME" $COMMANDLINE_PARAMETERS < /dev/null > /dev/null 2>&1 &
. See also the good answers at "Best way to make a shell script daemon" on Stack Overflow.
â AlexP
Jun 14 at 16:39
1
Please add the result of runninggrep 'KillUser' /etc/systemd/logind.conf
to your question, and
â roaima
Jun 15 at 8:36
 |Â
show 7 more comments
1
Welcome to Unix Stackexchange! You can take the tour first and the learn How to Ask a good question. That makes it easier for us to help you.
â andcoz
Jun 14 at 14:59
Is there any command in your interactive session that uses the service? Give us some pointer on the other script you are talking about.
â andcoz
Jun 14 at 15:02
Sorry, I'm not sure what you mean by "command in your interactive session thet uses the service". Do you want to know if I'm modifying the service while beeing logged in with ssh? To provocate a crash the only thing requiered is to login via ssh and then kill the session with "exit".
â Beny Benz
Jun 14 at 16:26
1
Instead of"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
try"nohup ./$BINARYNAME" $COMMANDLINE_PARAMETERS < /dev/null > /dev/null 2>&1 &
. See also the good answers at "Best way to make a shell script daemon" on Stack Overflow.
â AlexP
Jun 14 at 16:39
1
Please add the result of runninggrep 'KillUser' /etc/systemd/logind.conf
to your question, and
â roaima
Jun 15 at 8:36
1
1
Welcome to Unix Stackexchange! You can take the tour first and the learn How to Ask a good question. That makes it easier for us to help you.
â andcoz
Jun 14 at 14:59
Welcome to Unix Stackexchange! You can take the tour first and the learn How to Ask a good question. That makes it easier for us to help you.
â andcoz
Jun 14 at 14:59
Is there any command in your interactive session that uses the service? Give us some pointer on the other script you are talking about.
â andcoz
Jun 14 at 15:02
Is there any command in your interactive session that uses the service? Give us some pointer on the other script you are talking about.
â andcoz
Jun 14 at 15:02
Sorry, I'm not sure what you mean by "command in your interactive session thet uses the service". Do you want to know if I'm modifying the service while beeing logged in with ssh? To provocate a crash the only thing requiered is to login via ssh and then kill the session with "exit".
â Beny Benz
Jun 14 at 16:26
Sorry, I'm not sure what you mean by "command in your interactive session thet uses the service". Do you want to know if I'm modifying the service while beeing logged in with ssh? To provocate a crash the only thing requiered is to login via ssh and then kill the session with "exit".
â Beny Benz
Jun 14 at 16:26
1
1
Instead of
"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
try "nohup ./$BINARYNAME" $COMMANDLINE_PARAMETERS < /dev/null > /dev/null 2>&1 &
. See also the good answers at "Best way to make a shell script daemon" on Stack Overflow.â AlexP
Jun 14 at 16:39
Instead of
"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
try "nohup ./$BINARYNAME" $COMMANDLINE_PARAMETERS < /dev/null > /dev/null 2>&1 &
. See also the good answers at "Best way to make a shell script daemon" on Stack Overflow.â AlexP
Jun 14 at 16:39
1
1
Please add the result of running
grep 'KillUser' /etc/systemd/logind.conf
to your question, andâ roaima
Jun 15 at 8:36
Please add the result of running
grep 'KillUser' /etc/systemd/logind.conf
to your question, andâ roaima
Jun 15 at 8:36
 |Â
show 7 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f449815%2fservice-exits-after-ssh-disconnect%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Welcome to Unix Stackexchange! You can take the tour first and the learn How to Ask a good question. That makes it easier for us to help you.
â andcoz
Jun 14 at 14:59
Is there any command in your interactive session that uses the service? Give us some pointer on the other script you are talking about.
â andcoz
Jun 14 at 15:02
Sorry, I'm not sure what you mean by "command in your interactive session thet uses the service". Do you want to know if I'm modifying the service while beeing logged in with ssh? To provocate a crash the only thing requiered is to login via ssh and then kill the session with "exit".
â Beny Benz
Jun 14 at 16:26
1
Instead of
"./$BINARYNAME" $COMMANDLINE_PARAMETERS > /dev/null &
try"nohup ./$BINARYNAME" $COMMANDLINE_PARAMETERS < /dev/null > /dev/null 2>&1 &
. See also the good answers at "Best way to make a shell script daemon" on Stack Overflow.â AlexP
Jun 14 at 16:39
1
Please add the result of running
grep 'KillUser' /etc/systemd/logind.conf
to your question, andâ roaima
Jun 15 at 8:36