Run mitmproxy in the background

Is there a good way to run mitmproxy in the background? I’m writing a script to run mitmproxy 24/7 and save flows daily. Simple backgrounding doesn’t work.

mitmproxy &

I think I can get it done with screen.

screen -d -m mitmproxy

Does anyone know a cleaner way to do this?

Mitmproxy itself doesn’t support daemonisation - looking for an external tool to do this is the right way to go. Your idea of using screen (or tmux) is reasonable. There are also other systems for managing long-running terminal processes like this, like supervisord.