Auto Run And Record

Hello
I Have A Virtual machine That I Connect To With ssh! I Want When A Bash Started, Recording Starts!
When I put the command in bashrc, every time a bash is executed, an infinite loop is created that starts recording! How can I solve this problem?

When you login/connect initially set a flag/lock. Include code to check the existence of the flag/lock every time you login?

What @rkazak suggested is what people do in this case.

In fact, asciinema sets ASCIINEMA_REC=1 environment variable when you record.

You can put a conditional in your shell config file to check for this variable and start asciinema rec <filename> only when it’s not set.