sos 作业调度程序

发布于 2024-09-15 13:07:51 字数 282 浏览 5 评论 0原文

我正在使用支持多种语言的sos作业调度程序。我接受shell脚本来编写作业,但我不是shell脚本编写者。我想在作业调度程序中实现以下几点:

  1. 执行shell脚本A.脚本A返回“成功” " 如果时间在上午 6:00 到下午 3:00 之间。否则返回“失败”。
  2. “成功”时执行 shell 脚本 C,“失败”时执行 shell 脚本 B。
  3. 脚本 B 和脚本 C 发送主题行中包含“成功”或“失败”的电子邮件。

请帮我解决上述讨论的问题。

谢谢

i am using sos job scheduler which support many language.i accept the shell script to write jobs but i am not a shell script writer.i want to implement a following points in job scheduler:

  1. execute a shell script A. script A return "success" if time is between 6:00AM and 3PM.else it return "fail".
  2. on "success" execute a shell script C or on "Fail" it execute shell script B.
  3. Script B and Script C send email with“Success” or “Failure” in subject line.

please help me to sortout the above discuss problem.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

穿透光 2024-09-22 13:07:51

在这种情况下,有两个命令行实用程序很有用:

  • date:以指定格式显示当前时间/日期。
  • 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

There are two command line utilities that are helpful in this case:

  • date: Displays the current time/date in a specified format.
  • mail: Sends e-mail from the command line.

Since we only need the full hour for our logic I use the date format "+%H" (hour from 0-23). This gives the following script basis:

#!/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
情何以堪。 2024-09-22 13:07:51
#!/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"
#!/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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文