I have a python script that will write some general logging to the console. I've redirected this to a log file using the typical python -u jbot.py | tee -a jbot.log. This works fine, I get console output and logfile input. However, when attempting to run this under screen:screen python -u jbot.py | tee -a jbot.logI don't get any of the logging output to my file. Once I've disconnected from screen, does console output for that session get suppressed entirely, or is there a way I can still have logfile input from the stdout and stderr of my script?I realize using a logging library would probably solve this (since I'm screening anyhow), but for now I want to stick with capturing console output (if possible) until I can properly integrate a logging module into my code.
No logfile output when running script under screen, with console redirect (tee)
bash;gnu screen
You need to do something like this:screen sh -c 'python -u jbot.py | tee -a jbot.log'Basically, before you were piping the output of screen (not of your python script directly) to the log. Screen takes a command to execute as its argument, which it does itself not using a shell. So you need to explicitly make it run a shell.Another option is to use screen's built-in output logging; see the -L option (also available inside screen via its UI).