随笔 - 911  文章 - 5  评论 - 94  阅读 - 243万

crontab执行shell脚本

 

复制代码
#!/bin/bash
source /etc/profile #需要导入环境变量,否则非原生命令执行不成功

Sendmail(){
smtp='mail.yx.com'
account='he@yx.com'
password='123'
to='liu@yx.com'
subject=$1
content=$2
sendemail -f $account -t $to -s $smtp -u $subject -o message-charset=utf8 -xu $account -xp $password -m $content -o tls=no                                                                                                                                  }


res=`fs_cli -x "originate {absolute_codec_string=^^:PCMA,bridge_early_media=true,origination_caller_id_number=1007,origination_uuid=11035221997,origination_caller_id_number=11035221997,effective_caller_id_number=11035221997,                            effective_caller_id_name=11035221997}user/1007  11_Mogu_551113812266322" 2>&1`

echo "`date`, Mogu, $res" >>/usr/local/fs/scripts/fs.log 2>&1                                                                                                                                                                                       


if [ ${res: 0: 3} != '+OK' ];then
  #echo $res
  subject='Dial failed from Mogu'
  Sendmail "$subject" "${res: 1: 10000}"
fi
复制代码

 

crontab -l 内容:

2 8 * * * /bin/bash /usr/local/fs/scripts/mon_dial_mogu.sh
4 8 * * * /bin/bash /usr/local/fs/scripts/mon_dial_beishang.sh

posted on   momingliu11  阅读(364)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2016-10-28 Zabbix监控Windows事件日志
2014-10-28 查看系统和PowerShell版本
2014-10-28 批处理中的变量
2013-10-28 创建快捷方式,修改注册表
2013-10-28 常用组策略
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示