“批量清空日志”的版本间的差异
跳到导航
跳到搜索
(未显示同一用户的1个中间版本) | |||
第1行: | 第1行: | ||
+ | = sudo truncate= | ||
<pre> | <pre> | ||
#!/bin/bash | #!/bin/bash | ||
+ | # 如果sudo | ||
+ | # sudo truncate -s 0 /var/log/nginx/access.log | ||
# 删除 4月的日志 | # 删除 4月的日志 | ||
for loop in `ls | grep hello-wallet_2020-04` | for loop in `ls | grep hello-wallet_2020-04` | ||
第8行: | 第11行: | ||
done | done | ||
+ | </pre> | ||
+ | =echo= | ||
+ | <pre> | ||
+ | #!/bin/bash | ||
+ | #cd /data/storage/logs | ||
+ | for loop in `ls /data/storage/logs` | ||
+ | do | ||
+ | echo '' >/data/storage/logs/${loop} | ||
+ | |||
+ | done | ||
</pre> | </pre> | ||
2022年8月22日 (一) 01:58的最新版本
sudo truncate
#!/bin/bash # 如果sudo # sudo truncate -s 0 /var/log/nginx/access.log # 删除 4月的日志 for loop in `ls | grep hello-wallet_2020-04` do echo > $loop #echo $loop done
echo
#!/bin/bash #cd /data/storage/logs for loop in `ls /data/storage/logs` do echo '' >/data/storage/logs/${loop} done