内容简介:工作的时候,用到了Golang开发项目,将Golang打包(go build)生成执行文件,之后用nohup命令运行假设下面两句是先把
工作的时候,用到了Golang开发项目,将Golang打包(go build)生成执行文件,之后用nohup命令运行
nohup ./gopack &
假设 gopack
是生成的执行文件,上面的命令执行后,要在当前目录下生成一个 nohup.out
文件,在不停下进程的情况下, nohup.out
文件会越来越大,于是就打算对它切分另存并清空。
#!/bin/bash
thepath=/data/testshell
if [ ! -d "$thepath/log/" ];then
mkdir $thepath/log
fi
chmod -R 777 $thepath/log
if [ -f "$thepath/nohup.out" ];then
cpDate=`date -d "-1 day" "+%Y%m%d"`
cp $thepath/nohup.out $thepath/log/log_${cpDate}.log
cat /dev/null > $thepath/nohup.out
split -b 512 -d -a 4 $thepath/log/log_${cpDate}.log $thepath/log/log_${cpDate}_
rm -fr $thepath/log/log_${cpDate}.log
fi
下面两句是先把 nohup.out
复制,然后清空:
cp $thepath/nohup.out $thepath/log/log_${cpDate}.log
cat /dev/null > $thepath/nohup.out
用 split
命令对另存的文件切分
split -b 512 -d -a 4 $thepath/log/log_${cpDate}.log $thepath/log/log_${cpDate}_
最后删除另存的文件:
rm -fr $thepath/log/log_${cpDate}.log
以上所述就是小编给大家介绍的《处理nohup命令生成的大文件》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 如何实现一行命令自动生成 Flutter 插件
- AndroidStudio脚本命令指定AAR生成目录与版本号
- 安全不安全001:openssl生成非对称加密RSA公钥密钥命令
- mysql数据库一行命令生成GIN+GORM RESTful APIs Golang应用
- composer更新命令及常用命令
- Linux命令行与命令
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Google 广告高阶优化(第3版)
【美】Brad Geddes(布兰德.盖兹) / 宫鑫、康宁、王娜 / 电子工业出版社 / 2015-9 / 99.00元
《Google 广告高阶优化(第3版)》可以说是Google AdWords的终极指南,内容非常丰富,第三版在内容上进行了全面更新。介绍了AdWords的最新最完整的功能,阐释其工作原理,也提供了相应的优化方法、策略和实践教程,读者可以随时在自己的PPC广告系列中进行实践。第三版增添了50多页新内容,涵盖Google系统最近的所有变动,包括广告系列结构的变化、出价调整器、重定向、视频广告功能、全新......一起来看看 《Google 广告高阶优化(第3版)》 这本书的介绍吧!