“test-jb-setup”
http://icedot.blog.51cto.com/61369/477640
sudo: Sorry, you must have a tty to run sudo Error on a Linux and Unix 前面的括号表示用户身份,后面可以放多个命令或者目录
使用不同账户,执行执行脚本时候sudo经常会碰到 sudo: sorry, you must have a tty to run sudo这个情况,其实修改一下sudo的配置就好了 vi /etc/sudoers (最好用visudo命令) 注释掉 Default requiretty 一行
意思就是sudo默认需要tty终端。注释掉就可以在后台执行了。 http://chenall.net/post/linux-sudo-config/
“test-jb-setup”
定时任务 http://segmentfault.com/a/1190000002628040 基本格式 : * command 分 时 日 月 周 命令
定时任务: http://www.sjyhome.com/linux/crontab-doesnt-work.html
提示时间错误的问题,通过是中间没空格
http://blog.itpub.net/519536/viewspace-659881/
http://yaksayoo.blog.51cto.com/510938/155237
http://dengyong.blog.51cto.com/8409869/1425435
crontab 没执行问题,查看日志的时候发现 (root) MAIL (mailed 77 bytes of output but got status 0x004b#012)
“test-jb-setup”
传输
接受
调试
. /var/log/debugfmt;RSYSLOG_DebugFormat
http://blog.gerhards.net/2013/06/rsyslog-how-can-i-see-which-field.html
Debug line with all properties: FROMHOST: ‘10.171.254.94’, fromhost-ip: ‘10.171.254.94’, HOSTNAME: ‘10.171.254.94’, PRI: 13, syslogtag ‘nginx-access-wechat^^||{“@timestamp”:’, programname: ‘nginx-access-wechat^^||{“@timestamp”’, APP-NAME: ‘nginx-access-wechat^^||{“@timestamp”’, PROCID: ‘-‘, MSGID: ‘-‘, TIMESTAMP: ‘Feb 16 19:49:50’, STRUCTURED-DATA: ‘-‘, msg: ‘“2016-02-16T19:46:53+08:00”,”host”:”121.40.144.102”,”clientip”:”58.100.3.154”,”size”:”416”,”responsetime”:”0.009”,”httpxforwardedfor”:”-“,”timelocal”:”16/Feb/2016:19:46:53 +0800”,”request”:”POST /api/index/news/lastest HTTP/1.1”,”requestbody”:”{\x22device\x22:{\x22deviceId\x22:\x228f8a02e27855a189a28ea4babcc6264da333d441\x22,\x22os\x22:2,\x22versionNum\x22:\x221.0.7\x22,\x22netType\x22:\x22WIFI\x22,\x22versionCode\x22:\x221.0.7\x22,\x22ip\x22:\x22192.168.1.100\x22,\x22osVer\x22:\x228.2\x22}}”,”bodybytessent”:”416”,”upstreamtime”:”0.008”,”upstreamhost”:”10.252.91.197:8080”,”http_host”:”wechat.yaomaitong.cn”,”url”:”/api/index/news/lastest”,”xff”:”-“,”referer”:”-“,”agent”:”Medicine/1.0.7 (iPhone; iOS 8.2; Scale/3.00)”,”contentlength”:”168”,”httpreferer”:”-“,”httpcookie”:”-“,”httpreferer”:”-“,”agent”:”Medicine/1.0.7 (iPhone; iOS 8.2; Scale/3.00)”,”status”:”200”}’ escaped msg: ‘“2016-02-16T19:46:53+08:00”,”host”:”121.40.144.102”,”clientip”:”58.100.3.154”,”size”:”416”,”responsetime”:”0.009”,”httpxforwardedfor”:”-“,”timelocal”:”16/Feb/2016:19:46:53 +0800”,”request”:”POST /api/index/news/lastest HTTP/1.1”,”requestbody”:”{\x22device\x22:{\x22deviceId\x22:\x228f8a02e27855a189a28ea4babcc6264da333d441\x22,\x22os\x22:2,\x22versionNum\x22:\x221.0.7\x22,\x22netType\x22:\x22WIFI\x22,\x22versionCode\x22:\x221.0.7\x22,\x22ip\x22:\x22192.168.1.100\x22,\x22osVer\x22:\x228.2\x22}}”,”bodybytessent”:”416”,”upstreamtime”:”0.008”,”upstreamhost”:”10.252.91.197:8080”,”http_host”:”wechat.yaomaitong.cn”,”url”:”/api/index/news/lastest”,”xff”:”-“,”referer”:”-“,”agent”:”Medicine/1.0.7 (iPhone; iOS 8.2; Scale/3.00)”,”contentlength”:”168”,”httpreferer”:”-“,”httpcookie”:”-“,”httpreferer”:”-“,”agent”:”Medicine/1.0.7 (iPhone; iOS 8.2; Scale/3.00)”,”status”:”200”}’ inputname: imtcp rawmsg: ‘nginx-access-wechat^^||{“@timestamp”:”2016-02-16T19:46:53+08:00”,”host”:”121.40.144.102”,”clientip”:”58.100.3.154”,”size”:”416”,”responsetime”:”0.009”,”httpxforwardedfor”:”-“,”timelocal”:”16/Feb/2016:19:46:53 +0800”,”request”:”POST /api/index/news/lastest HTTP/1.1”,”requestbody”:”{\x22device\x22:{\x22deviceId\x22:\x228f8a02e27855a189a28ea4babcc6264da333d441\x22,\x22os\x22:2,\x22versionNum\x22:\x221.0.7\x22,\x22netType\x22:\x22WIFI\x22,\x22versionCode\x22:\x221.0.7\x22,\x22ip\x22:\x22192.168.1.100\x22,\x22osVer\x22:\x228.2\x22}}”,”bodybytessent”:”416”,”upstreamtime”:”0.008”,”upstreamhost”:”10.252.91.197:8080”,”http_host”:”wechat.yaomaitong.cn”,”url”:”/api/index/news/lastest”,”xff”:”-“,”referer”:”-“,”agent”:”Medicine/1.0.7 (iPhone; iOS 8.2; Scale/3.00)”,”contentlength”:”168”,”httpreferer”:”-“,”httpcookie”:”-“,”httpreferer”:”-“,”agent”:”Medicine/1.0.7 (iPhone; iOS 8.2; Scale/3.00)”,”status”:”200”}’
过滤
日志格式是一个坑,包含了路径和文件内容,容易弄错 地址也是一个坑,建议的tcp? 调试可以解决一部分问题 rawmsg好像会改变些什么,msg里面确实没有时间,raw里面的内容又太多了,有点奇怪的感觉,后来是通过模板补上的,或者换个词就好了?再看吧
日志分割方法,用脚本,用其他的,等等
“test-jb-setup”
很多情况下,我们需要查看端口使用情况,知道端口是否使用,什么进程在使用,流量等等,有几个命令可以查看
它的参数很多,目前用得比较多是 lntp 其中 l表示正在监听的端口 n表示尽量显示数字 t表示只显示tcp,对应的udp为u p表示进程id,需要root权限
netstat -lntp
lsof -i:3306
显示3306端口被谁占用
ss -tnl
查看监听地址
需要另外装,可以直接看各个端口的流量情况
以后把几个工具结合起来写吧,还有iftop等等
“test-jb-setup”
大多数情况下使用gunzip和tar,鲜有需要rar的时候,正好碰到,记录一下。
yum -y install libstdc++
yum -y install libstdc++.i686
wget http://www.rarsoft.com/rar/rarlinux-3.9.3.tar.gz
tar -xvf rarlinux-3.9.3.tar.gz
cd rar
make
cp rar unrar /usr/local/bin
cp rarfiles.lst /etc
cp default.sfx /usr/local/lib
#test.rar 到当前目录
rar x test.rar
# 把test001目录压缩为 test.rar
rar test.rar ./test001/
解决办法:
cp rar_static /usr/local/bin/rar