$ python >>> import os >>> os.getpid() 12252
参考:
http://stackoverflow.com/questions/8281345/how-to-get-current-linux-process-id-pid-from-cmdline-in-shell-and-language-i
$ python >>> import os >>> os.getpid() 12252
参考:
http://stackoverflow.com/questions/8281345/how-to-get-current-linux-process-id-pid-from-cmdline-in-shell-and-language-i
启动 supervisord
systemctl start supervisord.service
在 /etc/supervisord.d 创建 cat.ini
内容如下
[program:bar] command=/bin/cat stdout_logfile=syslog stderr_logfile=syslog
运行
supervisorctl update supervisorctl start all supervisorctl status bar RUNNING pid 681, uptime 0:05:53
命令选项
add
exit
open
reload
restart 重启
start 启动
tail
supervisorctl tail -f foo 日志
avail
fg
pid 获取进程号
remove
shutdown 关闭 supervisord
status 查看状态
update 更新
clear
maintail
quit
reread
signal
stop
version
用 watch 在测试的时候可以跟进输出
每一秒钟刷新一次
watch -n 1 'netstat -nat | grep 211.148.19.12'
如果想要持续性的查看,可以写到日志中
watch -n1 'netstat -nat | grep 211.148.19.12| tee -a netstat.log'
或者使用 sleep 来输出每一次的执行
while sleep 1; do netstat -nat | grep 211.148.19.12; done
如果都是 master 的话
git remote | xargs -n 1 git push
同一个 remote 有多个 push url, git push origin branch_name
[remote "origin"] url = [email protected]:jpuyy/terraform-gke.git fetch = +refs/heads/*:refs/remotes/origin/* pushurl = [email protected]:jpuyy/terraform-gke.git pushurl = https://self-managed-git.com/common/terraform-gke.git
➜ ansible-roles git:(master) ✗ git add todo.md fatal: Unable to create '/Users/jpuyy/ansible-roles/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.
解决办法
rm -f .git/index.lock
安装
yum install -y sysstat
使用 sar 可以监控 cpu, 内存, swap, I/O, load, network实时以及历史指定时间的值
定时任务文件
/etc/cron.d/sysstat
查看 cpu ,每 1 秒钟一次,共 3 次
sar 1 3
查看 内存使用
sar -r
查看 swap 使用
sar -S
查看 I/O,整个系统
sar -b
查看单个设备 I/O
sar -d
查看 context switch 上下文切换
sar -w
查看队列和负载情况
sar -q
查看网络情况
sar -n DEV 1
参考:
10 Useful Sar (Sysstat) Examples for UNIX / Linux Performance Monitoring