1. 每过一秒执行一次cmd命令 watch -n 1 cmd
2. shell中统计cmd执行时间 time cmd
3. kill匹配出的进程号
ps -ef | grep fireball | grep -v grep | awk '{print $2}' | xargs kill
kill `lsof -t -i:12301` # 按端口查找进程号kill
4. crontab配置 (分 时 日 月 周0-6)
0 8 * * * (source ~/.bash_profile && cd ~/xubc && ./load_to_wapstat.sh >> log/wap_stat.log 2>&1)
5. 查看系统当前最大文件夹
du -m /var/lib/mysql/ | sort -n -r | head -n 20
6. 查看去重后的结果列
cat t.log | awk '{print $2 $4 $5}' | uniq -c | wc -l
7. vim编辑器 set nu 查看行号 set list 查看特殊字符
8. curl发送http请求
curl -A "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0" -x 10.3.4.35:18080 -e "www.baidu.com" -i "http://10.3.4.34/hello.html"
9. root以某个用户身份执行命令
su - zookeeper -c '/data0/zookeeper/app/zookeeper-3.4.6/bin/zkServer.sh status'
10. ssh远程执行shell命令
ssh root@$hostname -nq "ps -ef | grep -w $topic | grep -v grep | wc -l"
11. 文件编码转换
iconv -f utf-8 -t gb18030 /tmp/v_st_union_userinfoutf8.txt -o /tmp/v_st_union_userinfo.txt;
12. scp传输文件,并限制带宽
find /tmp/hive -mtime +30 -name '*.pipeout' | xargs rm -f '*.pipeout'
14. 获取当前日期时间(天)
dt=`date -d "now 1 days ago " "+%Y%m%d"`
15. 运行脚本,重定向1>stdout, 2>stderr日志输出
cd recommend && sh recommend-als-i2i-loupan.sh > logs/recommend-als-i2i-loupan.log 2>&1
16. 复制文件目录,不改变文件的privilege, owner, time属性拷贝
cp -p /usr/local/hue/apps/oozie/src/oozie/templates/editor2/common_workflow.mako ~/templates
17. window文件转unix文件,并创建新的shell_unix.sh文件
dos2unix -n shell_windows.sh shell_unix.sh