I
I
IkaR492019-04-26 11:17:44
linux
IkaR49, 2019-04-26 11:17:44

Why does a script run by inetd run indefinitely?

Task: when opening a link in a browser on a computer, a script should run. Be sure to use inetd.
I register in /etc/services
myscript 1337/tcp
In /etc/inetd.conf

myscript  stream  tcp  nowait  root  /path/to/script.sh

Content /path/to/script.sh
#!/bin/sh
echo "It's work!" >> test.txt

I open the page localhost:1337 in the browser , check if the file exists - it is there. But it constantly writes new lines "It's work!". I break the connection in the browser, close the entire browser, the lines are still added, the file grows indefinitely.
Why does the script start to be called constantly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava, 2019-04-26
@Slava_ll

As far as I remember, initd is precisely in order to keep the service as long as there are active connections, then terminate it, but this is not a fact that the service will stop immediately. Depends on OS setting. Accordingly, the script is executed constantly and very many times per second.
I think you need to write a script so that it runs only once and forcibly ends or kills the service process.
For this, the curl utility should be suitable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question