【问题标题】:Running as a cron job failing to get output作为 cron 作业运行无法获得输出
【发布时间】:2019-04-06 23:18:43
【问题描述】:

当我执行下面的脚本时,它运行良好,并且我在电子邮件中收到了结果。但是当我将其作为 cron 作业运行时,它会发送 0 个代理。

我有一个下面的脚本 t(countagentid.sh)..

if [ -e /home/countagentid.csv ]
then
    rm -rf /home/countagentid.csv
fi

cqlsh -f countagentid.cql `hostname -I`  -u cassandra -p password -- (countagentid.cql has cql statment which will generate the output of cql query and save in csv format)
OUTPUT="$(cat /home/countagentid.csv |sort|uniq|wc -l)" --I sort & get the distinct values of the csv and assign it to $OUTPUT variable 
clustername=`cat /etc/cassandra/conf/cassandra.yaml |grep cluster_name |cut -f2 -d :`
mailalert(){
/sbin/sendmail -F Cassandra -it <<END_MESSAGE
To: test@gmail.com
Subject: Number of  agents in Cassandra $clustername

$OUTPUT  Number of  agents.
END_MESSAGE
}
mailalert

【问题讨论】:

    标签: linux cron centos7 datastax cassandra-3.0


    【解决方案1】:

    将脚本放在其他路径上。

    运行以下命令并共享输出日志。

    sh -x script_name.sh

    高塔姆·谢拉迪亚

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-20
      • 1970-01-01
      • 2014-02-02
      • 2017-07-08
      • 2013-03-16
      • 2011-11-17
      • 2016-08-21
      • 2023-04-02
      相关资源
      最近更新 更多