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?