linux - 作为 cron 作业运行无法获得输出

标签 linux cassandra cron cassandra-3.0

当我执行下面的脚本时,它运行良好,并且我在电子邮件中收到结果。但是当我将它作为 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

最佳答案

将脚本放在其他路径上。

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

sh -x 脚本名称.sh

高塔姆·谢拉迪亚

关于linux - 作为 cron 作业运行无法获得输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53123199/

相关文章:

java - 使用@Column获取变量

linux - shell 脚本 wget 在用作 cron 作业时不起作用

linux - "Visiting a page"使用 cron 作业

php - 数据库设计

python - Linux Python Scrapy 没有名为 six.moves 的模块

scala - 将 Cassandra 查询数据组合/更新到从 Kafka 接收的结构化流

cassandra - apache cassandra cluster(3.11.4) 10个节点的集群需要多少个种子节点

linux - 如何将 tail -1 输入到 sh 脚本 var

c++ - 跟踪生产 Linux 服务器上的内存损坏

linux - 比较 Unix/Linux IPC