一、模拟场景 (1)编写脚本test_del.sh,并执行 脚本内容 #!/bin/bash while true; do sleep 10000000 done (2)删除执行中的脚本 [root@dameng linuxscript]# rm test_del.sh rm: remove regular file 'test_del.sh'? yes [root@dameng…
alias tarthis='( ( D=`builtin pwd`; F=$(date +$HOME/`sed "s,[/ ],#,g" <<< ${D/${HOME}/}`#-%F.tgz); tar --ignore-failed-read --transform "s,^${D%/*},`date +${D%/*}.%F`,S" -czPf "$F" "$D" …
脚本内容 #!/bin/bash echo "User CPU Usage (%)" echo "---------------------------" ps -eo user,%cpu,comm,maj_flt,rss | awk ' NR > 1 { cpu[$1] += $2 } END { for (user in cpu) { printf("%-16s %.2f\n", u…
lsr() { find "${@:-.}" -print0 | sort -z | xargs -0 ls --color=auto -dlha; } 命令注释: ${@:-.}:传递给 lsr 函数的所有参数(即路径),如果没有提供参数,则以 . 作为起点(当前路径) -print0:处理特殊字符 sort -z:排序并处理特殊字符 xargs -0 ls --color=auto -dlh…
#!/bin/bash #备份归档 #创建备份归档目录 if [ ! -d "/backups" ]; then mkdir -p /backups fi for file in $(find /backups -name "backup-*" -type f | sort -r | tail -n +5); do rm -rf $file; done; ## /backups/back…
[dmdba@localhost log]$ gzip -c dm_DMSERVER_202403.log -c >/tmp/dm.out.log.20240424.gz && >dm_DMSERVER_202403.log 将日志文件 dm_DMSERVER_202403.log 重定向压缩到 /tmp/dm.out.log.20240424.gz 同时清空原始日志文件…
[root@localhost ~]# systemd-analyze plot >boot.svg 然后通过sz boot.svg命令将文件传输到本地,使用浏览器打开此文件即可。如下图
grep -i "failed password" /var/log/secure | awk '{if ($11 ~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) print $11 ; else print $13 }' | uniq -c | sort -nr -k1 > ~ip.txt 查看 ip.txt 文件结果 [ro…
命令 dd if=/dev/zero of=/dmdata/test.sdf bs=32k count=40k oflag=dsync 等待测试完成即可 [root@dameng ~]# dd if=/dev/zero of=/dmdata/test.sdf bs=32k count=40k oflag=dsync 40960+0 records in 40960+0 records o…
原文链接:https://eco.dameng.com/community/article/ede678e2d412f9b56a239bc3e574e311 一、事件背景 在一次配合应用开发商进行安全加固时,用户提出了需要对连接数据库的IP进行白名单配置,对于业务用户仅支持应用节点IP登录,对此我们提供了alter user的模板SQL对用户的网络白名单进行限制: alter user "SYS…