找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 24|回复: 2

一段简单的bash script

[复制链接]

178

主题

772

回帖

2188

积分

金牌会员

积分
2188
发表于 2013-8-5 15:50:31 | 显示全部楼层 |阅读模式
#!/bin/bash
#This is Mail sent a large number of intelligent bash script
#Write time 2013-8-4
#Author webjin
if [ `id -u` -ne 0 ]
        then
        echo "please use root running"
        su -
fi

if [ `ulimit -n` -le 1024 ]
then
   echo -e "speng soft nofile 10240\nspeng hard nofile 10240" >> /etc/security/limits.conf
   else
   break
   exit 1
fi
adword()
        {
        read -p "please write words ad" title
    echo "$title" >> title.txt
    read -p "please write words ad" content
    echo "$content" >> content.txt
        }

if [ -f ~/title.txt -a -f ~/content.txt -a -f ~/id.txt ]
   then
   echo  "the file true cun zai "
    adword
  else
  #touch {title,content,id}.txt
  adword
fi

Max=10000
for(( MID = 0 ;MID /dev/null| od -A n -t x4|sed s/[^1-9a-fA-F]//g`)) >> ~/id.txt
        
        done

for ID in `cat ~/id.txt`
    do
        
      mail -s " `  ~/id.txt;> /var/spool/mail/$SUER;
exit 0
==========================以上的参数需要很大cpu和内存、带宽才能操作,要不然你懂得
#!/bin/bash
#This is Mail sent a large number of intelligent bash script
#Write time 2013-8-4
#Author webjin
Max=500
for(( MID = 0 ;MID /dev/null| od -A n -t x4|sed s/[^1-9a-fA-F]//g`)) >> ~/id.txt
        
        done

for ID in `cat ~/id.txt`
    do
        
      mail -s " `  ~/id.txt;> /var/spool/mail/$SUER;
exit 0
=================以上脚本小内存的也可以操作,并且方便加入定时任务
#crontab -e
*/5 * * *  * /root/script_file_name  &

============================欢迎大家加入这个脚本编写当中大家进一步完善它
回复

使用道具 举报

178

主题

772

回帖

2188

积分

金牌会员

积分
2188
 楼主| 发表于 2013-8-5 15:54:02 | 显示全部楼层
对了前提要装sendmail服务
回复

使用道具 举报

36

主题

231

回帖

622

积分

高级会员

积分
622
发表于 2013-8-5 21:35:52 | 显示全部楼层
我最近也在重写以前的一个用邮箱备份数据的shell,不过没有打算使用sendmail,而是直接使用/dev/tcp
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Discuz! X

GMT+8, 2025-4-22 10:05 , Processed in 0.015798 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表