【无标题】

1、编写脚本,判断当前系统剩余内存大小,如果低于100M,邮件报警管理员,使用计划任务,每10分钟检查一次。

vim men.sh
	#!/bin/bash
	men=`free -m | grep Men | tr -s " " " " | cut -d " " -f 4
	if [[ $men -lt 100 ]];then
		echo "内存不足"|mail -s 内存报警 admin@admin.com
	fi
crontab -e
	*/10 * * * * /men.sh
	tail -f /var/log/cron

第一题

1.判断某个文件是否存在,若不存在则给一个Filename does not exist的信息,并终端程序;
⒉若文件存在,则判断它是文件或者目录,结果输出Filename is regular file或者Filename is directory.
3.判断下,执行者的身份对这个文件或者目录所有的的权限,并输入权限数据、

#!/bin/bash
read -p "请输入名称:" mingcheng
if [[ -e $mingcheng ]];then
	if [[ -f $mingcheng ]];then
		echo "Filename is regular file";ls -l $mingcheng
	else
		if [[ -d $mingcheng ]];then
			echo "Filename is directory";ls -l -d $mingcheng
		fi
	fi
else
	echo "Filename does not exist";exit 7 
fi
		

第二题

1.当执行一个程序的时候,这个程序会让用户选择Y或N
2.如果用户输入Y或者y时就显示ok,continue
3.如果用户输入N或者n时,就显示oh,interrupt
4.如果不是Y/y/N/n之内的其他字符,就显示I don’t know what your chocie is

#!/bin/bash
read -p "请输入Y或N:" huang
if [[ $huang =~ ^[YyNn]+$ ]];then
	if [[ $huang =~ ^[Yy]+$ ]];then
		echo ok,continue
	else
		echo oh,interrupt
	fi
else
	echo "I don't know what your chocie is"
fi

第三题∶

1.程序的文件名是?
2.共有几个参数
3.若参数的个数小于2则告知使用者数量太少
4.全部参数内容是什么
5.第一个参数是什么
6第三个参数是什么

#!/bin/bash
name=$0
echo "文件名是$name"
quantity=$#
echo "参数个数:$quantity"
[[ $quantity -le 2 ]] && echo "参数数量太少了"
content=$*
echo "参数内容:$content"
first=$1
echo "第一个参数是:$first"
third=$3
echo "第三个参数是$third"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值