Akhil Surapuram
Akhil Surapuram

Reputation: 682

killing a child process which has been created by shell script so that i will execute next commands

i have a shell script which performs certain task

In between of script there is a command which ideally runs for infinite time

tail -f

con see the output which is logging.

Usually tail -f can be exited by ctrl + z or Ctrl + c In this case when i do that it will also exits my shell which has to perform.

after this command script will perform other commands which usually performs cleaning task.

Is there a any way to exit from tail command and not exiting execution of shell script.

I have found some way like find the process of tail and kill that process but those will be a very hard blocker for automation with shell script.

Upvotes: 0

Views: 25

Answers (1)

Akhil Surapuram
Akhil Surapuram

Reputation: 682

We can user interrupt in shell command

like trap or onitr

we need to register task what has to be performed after receiving signal

to do that

for suppose you want to interrupt with ctrl + c

trap "your resume script/ command" INT

it will register to run rest of the script after receiving your single form keyboard

Upvotes: 0

Related Questions