我使用支持多种语言的sos作业调度器。我接受shell脚本来编写作业,但我不是shell脚本编写器。我想在作业调度器中实现以下几点:
请帮我整理一下上面讨论的问题。
谢谢
发布于 2010-08-19 15:01:19
在本例中,有两个命令行实用程序是有用的:
date:在指定的format.mail:中显示当前时间/日期,从命令行.发送电子邮件。
因为我们的逻辑只需要整整一个小时,所以我使用了日期格式"+%H“(从0到23的小时)。这提供了以下脚本基础:
#!/bin/sh
hour=$(date +%H)
if [ $hour -gt 6 -a $hour -lt 15 ]; then
echo "message body" | mail -s Success <your e-mail address>
else
echo "message body" | mail -s Failure <your e-mail address>
fi发布于 2010-08-20 04:16:28
#!/bin/bash
hour=$(date +%H)
recipient="root"
case "$hour" in
[6-9]|1[0-5])
subject="success"
body="message"
;;
*)
subject="failure"
body="message"
;;
esac
echo $body | mailx -s "$subject" "$recipient"https://stackoverflow.com/questions/3509377
复制相似问题