linux - script gives wrong output in crontab -
my problem is, when run below script manually shell, runs perfectly. when put in crontab, gives wrong output. tried related env variables.
#!/bin/bash -x source /home/username/.profile export path=$path:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/mailsend/bin:~/script_folder/ export shell=/bin/bash sshpass -p "password" ssh -t "user"@x.x.x.x '(mysql -uuser db -e "select xxxxx xx;")'|grep -v "warning:"|/usr/bin/tr -s ' ' '|' | /usr/bin/awk -f"|" 'nr > 3{gsub("y","ok",$3) gsub("n","nok",$3); print "*"$2":"$3}'|/bin/sed '$ d' > output.txt
as per comments, tried running command first part [ sshpass -p "password" ssh -t "user"@x.x.x.x '(mysql -uuser db -e "select column_x,column_y xx;")' ] crontab , interactive , gives different outputs below:
crontab output:
column_x column_y 222 y 111 n 888 y
interactive output:
+--------------+-----------------+ | column_x | column_y | +--------------+-----------------+ | 222 | y | | 111 | n | | 888 | y | +--------------+-----------------+
could tell me why, , how make crontab output interactive shell ?
Comments
Post a Comment