- 论坛徽章:
- 0
|
各位大侠,有没有写过一个自动的telnet登入,登出的程式?
Use crontab Sample:
shell name: chkdisk.sh
#!/bin/ksh
# Check Harddisk Space
MailBox="your@mail.address"
TmpFile="/tmp/df.txt"
TmpMsg="/tmp/df.msg"
df -k | grep 'dev' >; $TmpFile
while read LINE
do
Dev=`echo $LINE | awk '{print $1'}`
Use=`echo $LINE | awk '{print $4'} | sed -e 's/%//g'`
Mnt=`echo $LINE | awk '{print $7'}`
if [ $Use -gt 90 ]; then
echo "Attention: $Dev ( $Mnt ) Disk space not enought ( used $Use % )!!" >;>; $TmpMsg
fi
done < $TmpFile
if [ -s $TmpMsg ]; then
mail -s "System Disk Space Not Enought!!" $MailBox < $TmpMsg
rm $TmpMsg
fi
rm $TmpFile
# Shell End
use "crontab -e" to add new cron job, ex:
1 * * * * /path/chkdisk.sh 1>;/dev/null 2>;/dev/null |
|