G
G
GeekFromUa2014-10-12 10:05:22
linux
GeekFromUa, 2014-10-12 10:05:22

How to properly terminate a process in Linux from a bash script?

I want to save audio stream via wget command. In order to save the specified time, you need to end the process after a delay.
Here is an example code:

wpid=$!
sleep 60;
kill -1 $wpid

Question 1 - What could be the reason that the kill command is not working? wpid is assigned to the process id, echoed out, but kill does not kill this process. Although if you write a command in the console, then everything works fine.
Question 2 - Why in the sleep command, if you do not put a semicolon, symbols appear near the number and the delay does not work?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
GeekFromUa, 2014-10-14
@petriychuk

It's all about gedit, after creating the file in the nano editor, everything worked fine.

J
jcmvbkbc, 2014-10-12
@jcmvbkbc

If I were you, I'd start with wget --timeout=<...>
If that doesn't work, I'd continue with timeout -k 1 <...> wget
you are doing something wrong. Please provide the full text of the script.

E
egor_nullptr, 2014-10-12
@egor_nullptr

wget -q ..... &
echo "kill -s TERM $!" | at "now + 1 min"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question