无法使用crontab发送Java邮件,但从终端运行时效果很好

时间:2018-11-18 20:49:15

标签: java linux shell ubuntu

我有一个Shell脚本,用于通知Java进程。手动运行时脚本正在发送邮件,但是当我在crontab中添加脚本时,它似乎跳过了Java邮件发送代码并执行下一行。  EmailSender是一个Jar文件,它从args获取输入参数

#!/bin/bash
echo "Process Monitor"
CHECK_ALERT=$(ps aux | grep Alert.jar | grep -v grep | wc -l)
CHECK_LISTENER=$(ps aux | grep Listener.jar | grep -v grep | wc -l)
#Check Listener Jar
if [ "$CHECK_LISTENER" = 0 ]
then
        #Send Mail when service is stopped
        nohup java -jar EmailSender.jar xyz@gmail.com  Listener_DOWN Listener_Service_Stopped_Please_Contact_To_Admin & 
        java -jar /root/john/list $
else
        echo "Listener already running"
fi

#Check Alert Jar
if [ "$CHECK_ALERT" = 0 ]
then
        #Send Mail when service is stopped
        nohup java -jar EmailSender.jar xyz@gmail.com  ALERT_DOWN Alert_Service_Stopped_Please_Contact_To_Admin & 
        java -jar /root/john/alert/Alert.jar &     
else
        echo "Alert already running"
fi

0 个答案:

没有答案