Generally, to make the risk of getting banned as low as possible, only bot while you'd normally be playing.
Obviously this semi-defeats the purpose, but if you don't wanna get banned, that's the best route to go. If you know you're only gonna be out for an hour or something, I guess you could leave it running for that long, since Jagex isn't really going to know you left for that hour if you're usually playing during that hour, but don't leave it overnight unless you're feeling like risking a ban.