Python's standard output is not written to a file when executed in the background with nohup and &, so using Loguru for log output

2 min

language: ja bn en es hi pt ru zh-cn zh-tw

Hello, I'm incompetent.

I tried to write the output from a bot that performs automatic looping to a file, but it didn't work out.

nohup ./xxx.py >> txtfile &

So, I thought, "What about logging?" and casually searched, then found something called Loguru.

loguru · PyPI - https://pypi.org/project/loguru/

I'm updating this from my phone while out, so I can't write details, but it allows for easy logging, so it can be used when you want to output to a file in real-time without question.

It seems highly versatile because you can simply output logs from a regularly scheduled script using the above method, and also put a script that executes when a matching log is output into cron to run simultaneously.