TORONTO -- Justin Theroux got some useful advice when it came to being in the spotlight while he was married to Jennifer Aniston.

Theroux appeared on "Today," where host Willie Geist asked: "Was that a shock to your system though? Ten years ago when you started dating Jennifer and got married, all that attention that you got?"

Theroux, who was promoting his new Apple+ TV show "The Mosquito Coast," said it was their friend Jason Bateman who offered insight about managing media focus on his relationship with Aniston.

"Yeah, I think part of me was like, you know, I'm essentially sort of a character actor and a writer, there's not much there," Theroux recalled. "Jason Bateman actually once gave me one of the most sage pieces of advice ever when all that was kind of going on."

He continued, "And he said, 'Look, in that side of the entertainment industry, a character is about to be born and that character is you, but it's not you. That character is, you know, angry, that character has got a problem, that character is, you know, sweet. It's just this little soap opera that gets written in the margins.' And he said, 'And so my advice is, don't follow that guy's storyline.' "

Theroux said he listened and it helped.

"I stuck to it," he said. "And that's the only way you can sort of keep sane and all that."

Aniston and Theroux first went public with their relationship in 2011 and married in a backyard ceremony in California in August 2015. They split in early 2018.