Linux相关知识

来源:互联网 发布:linux vi定位到某一行 编辑:程序博客网 时间:2024/06/03 02:43

本文章专门记录Linux系统的相关知识,用于查缺补漏。

1、转码:

linux系统里提供的文件转化编码的命令iconv,使用如下:
 

iconv -t utf-8 -f gb2312 -c my_database.sql > new.sql

-f     原编码
-t     目标编码
-c    忽略无法转换的字符

2、Nohup is not writing log to output file

I am using the following command to run a python script in the background.
nohup python ./cmd.py > cmd.log &
But it appears that nohup is not writing anything to the log file.

Answer:
python as well as other C stdio- based programs uses line-buffering in interactive  case and block-buffering when redirected to a file. if python -u does'n works; nohup might have introduced its own buffering. So,we can run python with -u flag to avoid output buffering:
nohup python -u ./cmd.py > cmd.log &



0 0
原创粉丝点击