I am running a shell command which is invoking an avconv session.

The command is running as a background process. When the script starts executing I am doing a curl post to a url with the created process id. And that is working perfectly. But how can I do another curl post when the process getting killed or died?

The script right now, I am running is:

avconv -i rtsp://ipaddress/axis-media/media.amp -r 3 -g 3 -vcodec h264 -c:v libx264 -f mpegts udp:// & curl --request POST "http://myipaddress/receivce.php" --data "pid=${!}" 

1 Answer 1


If there is nothing to be done after curl:

while true; do
  avconv ... &
  curl ... "pid=${!}"
  wait $! && break
  • it is working perfectly. Thank you very much.
    – fortune
    Feb 4, 2015 at 7:28
  • one doubt, why you are using while loop, is it necessary?
    – fortune
    Feb 4, 2015 at 7:30
  • @fortune You have to check how the program exited and you don't know in advance how often it will report failure. How do you want to handle that without a loop? Feb 4, 2015 at 10:31
  • after && i can do a curl post regarding the the avconv process termination. But the reason for failure will not be available.
    – fortune
    Feb 4, 2015 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.