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…
一、问题描述 如何删除目录下大量文件【保留指定文件】。 如果某目录下有70000个文件,要快速地删除,并需要保留其中的几个文件,那么该怎么做呢? 二、问题解决 首先还涉及到另一个问题:如何快速列出这70000个文件? [root@primary linuxscript]# time ls -l &>/dev/null real 0m0.850s user 0m0.374s …
为了测试程序在弱网环境下的表现,通常需要创造一个“不那么稳定”的网络环境,但这种模拟十分不好控制变量,比如希望控制网络延迟在700ms时,现实环境则是难以实现的,那有什么解决的办法呢? 可以在Linux下使用tc命令来模拟延迟。 配置网络延迟700ms tc qdisc add dev eth0 root netem delay 700ms 配置后,测试网络 [root@primary …