随笔分类 -  Linux/Unix系统管理脚本

1
系统管理工作中记录的一些问题解决方法及AWK、Shell编程实现
摘要:之前一直以为,touch命令的原本意图是创建文件,这也是我们运行touch的大部分场景。 今天,看到了官方手册页的描述,touch - change file timestamps,刷新了认知。 原来touch是修改文件的时间戳的。 Update the access and modificatio 阅读全文
posted @ 2023-04-23 17:06 东宫得臣 阅读(24) 评论(0) 推荐(0) 编辑
摘要:有一套比较旧的环境,BIND 9.8.2,开发反馈,dig ns . 居然没有glue record返回,甚是奇怪。 检查了配置文件,网上也查了很多,后来在官方网址找到了原因。 解释就是A/AAAA资源记录被丢掉了,导致根本没有glue record. 官方kb 原来是bind 9.8.2的版本bu 阅读全文
posted @ 2022-03-25 11:31 东宫得臣 阅读(128) 评论(0) 推荐(0) 编辑
摘要:直接先上man文档得到的结果: +[no]trace Toggle tracing of the delegation path from the root name servers for the name being looked up. Tracing is disabled by defau 阅读全文
posted @ 2022-03-25 10:41 东宫得臣 阅读(1253) 评论(0) 推荐(0) 编辑
摘要:对每个文件维护3个时间字段, st_atime 文件数据的最后访问时间(read) st_mtime 文件数据的最后修改时间(write) st_ctime i节点状态的最后更改时间(chmod、chown) 修改时间是文件内容最后一次被修改的时间,状态更改时间是该文件的i节点最后一次被修改的时间。 阅读全文
posted @ 2021-07-22 09:48 东宫得臣 阅读(70) 评论(0) 推荐(0) 编辑
摘要:发现一篇文章,讲解这两个之间的区别,很详细。 find -exec vs find | xargs (everythingcli.org) 阅读全文
posted @ 2021-07-12 14:31 东宫得臣 阅读(39) 评论(0) 推荐(0) 编辑
摘要:在操作系统为Redhat 7.4的服务器上的一次Python 3.8.2的安装 1)首先搞明白操作系统自带的python的安装路径:whereis python,可以看到初始的路径在/usr/bin/python。 cd /usr/bin; ll | grep python,python作为符号链接 阅读全文
posted @ 2020-04-22 13:57 东宫得臣 阅读(1591) 评论(0) 推荐(0) 编辑
摘要:#!/bin/bash cat iplist | while read ip username do printf "${ip}, ${username}, " eval $(ssh -q ${ip} "awk -v user_name=$username -F':' '\$0 ~ user_nam 阅读全文
posted @ 2019-11-27 13:14 东宫得臣 阅读(265) 评论(0) 推荐(0) 编辑
摘要:prochapawd.sh #!/usr/bin/expect set timeout 5 set ipaddress [lindex $argv 0] set username [lindex $argv 1] set newpassword [lindex $argv 2] spawn ssh 阅读全文
posted @ 2019-11-26 17:56 东宫得臣 阅读(212) 评论(0) 推荐(0) 编辑
摘要:- hosts: myjob gather_facts: True vars: IP: "{{ ansible_default_ipv4['address'] }}" HOST_NAME: "{{ ansible_hostname }}" OS: "{{ ansible_distribution } 阅读全文
posted @ 2019-11-26 15:32 东宫得臣 阅读(2552) 评论(0) 推荐(0) 编辑
摘要:统计cpu和内存一个月的平均使用率: #!/bin/bash totalcpu_rate=0.0 totalmem_rate=0.0 num_days=$(ls -l /var/log/sa/sa[0-3]* | wc -l) echo $num_days for file in /var/log/ 阅读全文
posted @ 2019-11-26 14:58 东宫得臣 阅读(1131) 评论(0) 推荐(0) 编辑
摘要:- hosts: myjob gather_facts: false tasks: - name: chage user passwd user: name={{ item.name }} password={{ item.chpass | password_hash('sha512') }} up 阅读全文
posted @ 2019-11-26 14:49 东宫得臣 阅读(442) 评论(0) 推荐(0) 编辑
摘要:{ if(NR % 2 == 0) printf("%s\n", $0) else printf("%s, ", $1) } awk -f awk.awk data 阅读全文
posted @ 2019-11-26 14:41 东宫得臣 阅读(190) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/env python3 # -*- coding: utf-8 -*- import paramiko import os, stat import sys import operator as op from string import Template def ssh_co 阅读全文
posted @ 2019-06-04 12:34 东宫得臣 阅读(319) 评论(0) 推荐(0) 编辑
摘要:{ if(NF==1 && $0~/192.168/) host_name = $0 for(i=1;i<NF;++i) { if($i~/192.168/) { split($i, a, "=") printf("%s, %s\n", host_name, a[2]) } } } 原始数据: 19 阅读全文
posted @ 2019-04-10 15:57 东宫得臣 阅读(159) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/ksh touch hostinfo$(date +%Y%m%d).csv filename=hostinfo$(date +%Y%m%d).csv >${filename} for ip in $(cat iplist); do SYSTEM=`ssh -q ${ip} un 阅读全文
posted @ 2019-03-31 19:30 东宫得臣 阅读(142) 评论(0) 推荐(0) 编辑
摘要:# awk.awk { if(data[$0]++ == 0) lines[++count] = $0} END { for (i=1;i<=count;i++) print lines[i]} 脚本用法如下: awk -f awk.awk text_to_process cat text_to_p 阅读全文
posted @ 2018-09-27 07:29 东宫得臣 阅读(259) 评论(0) 推荐(0) 编辑
摘要:##########mianmi.sh############ #!/usr/bin/expect set ip [lindex $argv 0] set password [lindex $argv 1] spawn ssh -o ConnectTimeout=5 -l root ${ip} ex 阅读全文
posted @ 2017-06-23 16:50 东宫得臣 阅读(318) 评论(0) 推荐(0) 编辑
摘要:在一行中,查找字段包含exe的: ###########awk.awk######## { for(i=1;i<=NF;i++) { if($i ~ /exe/) { print $i } } } test_to_process是要处理的文件,执行如下命令: awk -f awk.awk text_ 阅读全文
posted @ 2017-06-23 16:29 东宫得臣 阅读(4044) 评论(0) 推荐(0) 编辑
摘要:文件系统巡检脚本,输出使用率大于70%的,适用于HP-UNIX、Linux和AIX; 门限值可以调整,可以把70换成实际你需要的。 #!/usr/bin/ksh###################################################################### 阅读全文
posted @ 2017-06-23 15:33 东宫得臣 阅读(181) 评论(0) 推荐(0) 编辑
摘要:HP Unix vsftp 服务配置: /opt/ssh/utils/ssh_chroot_setup.sh 运行脚本,会提示输入要建立的vsftp账号和要限制的家目录, 比如要限制的家目录为/JiaRoot/,则/etc/passwd 里面相应的vsftp账号家目录 /JiaRoot/./; 配置 阅读全文
posted @ 2017-06-23 08:35 东宫得臣 阅读(464) 评论(0) 推荐(0) 编辑

1
点击右上角即可分享
微信分享提示