[英]Script works fine manually but not working on crontab
My script is working manually but not working on crontab.I read all topics about this issue I tried so many things to execute via crontab but didnt work. 我的脚本是手动工作的,但不能在crontab上工作。我阅读了有关此问题的所有主题,我尝试了许多通过crontab执行的事情,但没有成功。
My script is below. 我的脚本在下面。
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
nodetool status > cqlsh_control.txt
cs1=`more cqlsh_control.txt | awk '{print $1}' | sed -ne 6p | cut -d"%" -f1`
SLACK_ICON=":red_circle:"
if [ "$cs1" != "UN" ]; then
curl -S -X POST --data "payload={\"text\": \"{Cqlsh is not responsing Cassandra2} \",\"username\":\"CQLSH\",\"icon_emoji\":\"${SLACK_ICON}\"
}" https://hooks.slack.com/services/T05xxxxW/B7xxxxxx09/QdotCzoxxxxxxxHxOsrnjS
fi
Edit the crontab and put shell /bin/sh before script like below. 编辑crontab并将shell / bin / sh放在如下脚本之前。
*/1 * * * * /bin/sh /home/ec2-user/cqlsh_control.s * / 1 * * * * / bin / sh /home/ec2-user/cqlsh_control.s
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.