service exits after ssh disconnect

The name of the pictureThe name of the pictureThe name of the pictureClash 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 &






share|improve this question

















  • 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















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 &






share|improve this question

















  • 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













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 &






share|improve this question













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 &








share|improve this question












share|improve this question




share|improve this question








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 running grep 'KillUser' /etc/systemd/logind.conf to your question, and
    – roaima
    Jun 15 at 8:36













  • 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








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
















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















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



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay