上周迁移几台机器环境,一个模块的机器磁盘只有40G,总是会出现No space left on device的报错。需要写一个定时任务删除日志文件,并设置机器人提醒。由于之前从未写过shell,花了点时间。
思路
- 定时任务 crontab * * * * * xxx.sh
- 磁盘用量 dh -lf 检查
- hi机器人接口报警
- 自动删除
#!/bin/bash
. /etc/profile
. ~/.bash_profile
df -lh | while read line
do
disk_used=`echo $line | awk '{print $5}' | tr -cd "[0-9]"`
if [[ $disk_used -gt 90 ]] ; then
echo '磁盘容量超过使用,调用机器人'
result=$(curl --location --request GET 'http:xxx')
access_token=