ls -Sl|awk '$5>800000{ print $9 }'|xargs tar cf test.tar
分类目录归档:Linux开发
按文件创建日期进行同步
#!/bin/bash
time_now=`ssh -l root 172.17.101.163 "date +%s"`
rooms=`ssh -l root 172.17.101.163 "ls /home/waypal/volume/kms/kms-media"`
for room in $rooms
do
read -t 5 -p "continue ? [y/n default y]" answer
answer=${answer:-y}
echo "you choise:$answer"
if [ $answer != y ];then
exit;
fi
echo "/home/waypal/volume/kms/kms-media/$room"
time_lastchanged=`ssh -l root 172.17.101.163 "stat -c %Y /home/waypal/volume/kms/kms-media/$room"`
time_ago=$[ $time_now - $time_lastchanged ]
if [ $time_ago -gt 3600 ];then
#echo "$time_now,$time_lastchanged,$time_ago"
rsync -av --progress -e ssh root@172.17.101.163:/home/waypal/volume/kms/kms-media/$room $HOME/waypalers.cn/waypal/shared/resources/records && ssh root@172.17.101.163 "rm -r /home/waypal/volume/kms/kms-media/$room";
fi
done
rails数据库配置获取
获取数据库的配置
Waypal::Application.config.database_configuration
查看docker的IP地址
容器内部
cat /etc/hosts
---------------------------------
宿主机
1.docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
2a0fddf3b486 mysql:latest "docker-entrypoint.sh" 3 weeks ago Up 2 days 0.0.0.0:3306->3306/tcp
2.docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 2a0fddf3b486
添加EPEL源
[root@localhost ~]# wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@localhost ~]# rpm -ivh epel-release-latest-7.noarch.rpm
[root@localhost ~]# yum repolist ##检查是否已添加至源列表
OK,检查好已添加至源后就可以进行yum安装了
VMWare端口映射
在进行kms的例子测试时,发现快速试验kurento的最佳方式就是【kurento-tutorial-java】+【kurento/kurento-media-server】,然而笔记本摄像头在linux中不被支持,故通过VMware把linux中的kms端口映射到主机中。
ssh的反向代理,连接回家庭电脑。
path_script=$(cd "$(dirname "$0")"; pwd)
mode=$1
#公网IP
host_proxy=39.108.x.y
#公网相应主机登录名
host_proxy_user_name=abc
#使用密码方式登录,非免密码方式。需要yum install sshpass软件。
#公网主机的用户密码,免密码方式时为空。
host_proxy_user_pwd=
#需要被登录的家庭主机登录名。
local_user_name=abc
ssh_process=`ps -ef | grep "ssh -fN -R 5022"| grep -v grep`
echo $ssh_process
case "$mode" in
'start')
echo "it's ready to start op...."
if test -n "$ssh_process"; then
echo ""
echo "---the ssh reverse proxy info below"
echo "$ssh_process"
echo ""
else
if [ -z "$host_proxy_user_pwd" ]; then
echo "ssh -fN -R 5022:localhost:22 $host_proxy_user_name@$host_proxy"
ssh -fN -R 5022:localhost:22 $host_proxy_user_name@$host_proxy
else
echo "sshpass -p $host_proxy_user_pwd ssh -fN -R 5022:localhost:22 $host_proxy_user_name@$host_proxy"
#如果使用``方式执行,无法执行它,真是奇怪。
sshpass -p $host_proxy_user_pwd ssh -fN -R 5022:localhost:22 $host_proxy_user_name@$host_proxy
fi
fi
echo 'success to start.'
echo "you can test on proxy host:$host_proxy,use the follow commands "
echo 'netstat -nap | grep 5022'
echo "ssh -p 5022 $local_user_name@localhost"
echo "sshpass -p 123 ssh -p 5022 abc@localhost"
;;
'stop')
echo "it's ready to check process..."
if test -n "$ssh_process"; then
echo "had find ssh rever proxy process informaton"
echo "$ssh_process"
echo $ssh_process | awk '{print ($2)}' | xargs kill -9
fi
echo 'success to kill.'
;;
*)
basename=`basename "$0"`
echo "Usage: $basename {start|stop} [ server options ]"
exit 1
;;
esac
exit 1
自定义菜单和修改桌面图标大小
LINUX CENTOS 7 X86_64中开始菜单的编辑安装软件alacarte即可
命令:$ yum install alacarte
安装好后在Application->sundry中就能看到“Main Menu”的选项了。
点击“Main Menu”就可以很方便的对菜单进行编辑。
修改桌面图标大小
源码备份脚本
\#!/bin/bash
set -x
path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)
echo "path_script="$path_script
path_waypal=$path_script/waypal.from.101.200.132/waypal
if [ -d $path_waypal ];then
echo "find the directory:$path_waypal"
else
mkdir -p $path_waypal
fi
path_targz=$path_script/waypal.from.101.200.162/waypal_backup_`date +%Y-%m-%d`.tar.gz
path_targztmp=$path_targz'.tmp'
rsync --exclude ".git" -ave ssh ljb@101.200.132:/home/ljb/waypal $path_waypal && tar -cvzf $path_targztmp $path_waypal && mv $path_targztmp $path_targz && rm $path_script/waypal.from.101.200.132/waypal_backup_`date -d '-5 days' +%Y-%m-%d`.tar.gz
获取当前目录脚本
#!/usr/bin/bash
path_current=$(cd "$(dirname "$0")"; pwd)
name_current=$(basename "$0" .sh)
echo $path_current
echo $name_current
rm -vf $path_current/backup/"$name_current"_`date -d '-10 days' +%Y-%m-%d`*.sql.gz
mysqldump -h waypaldb.mysql.rds.aliyuncs.com -u waypal -p'1234567' --databases waypaldev | gzip > $path_current/backup/"$name_current"_`date +%Y-%m-%d-%H-%M`.sql.gz