nohup 本身不控制日志编码,它只是把程序输出重定向到文件(默认 nohup.out)。
日志文件的编码,取决于程序输出时使用什么编码。
下面按常见场景说明怎么改。
nohup java -Dfile.encoding=UTF-8 -jar app.jar > nohup.out 2>&1 &
✅ 重点参数:
-Dfile.encoding=UTF-8nohup env PYTHONIOENCODING=utf-8 python app.py > nohup.out 2>&1 &
import sys
sys.stdout.reconfigure(encoding='utf-8')
nohup env LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 sh run.sh > nohup.out 2>&1 &
iconv -f GBK -t UTF-8 nohup.out > nohup_utf8.out
file nohup.out
# 或
enca nohup.out
nohup env LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 \
your_command > nohup.out 2>&1 &
如果你能告诉我:
我可以给你精确命令。