0

I am trying to execute snowsql from an shell script which i have scheduled with cron job. But i am getting error like snowsql: command not found.

I went through many links where they are asking us to give full path of the snowflake. i tried with that also but no luck. https://support.snowflake.net/s/question/0D50Z00007ZBOZnSAP/snowsql-through-shell-script. Below is my code snippet abc.sh:

#!/bin/bash
set -x
 snowsql --config /home/basant.jain/snowsql_config.conf \
-D cust_name=mean \
-D feed_nm=lbl \
-o exit_on_error=true \
-o timing=false \
-o friendly=false \
-o output_format=csv \
-o header=false  \
-o variable_substitution=True \
-q 'select count(*) from table_name'  

and my crontab looks like below:
*/1 * * * * /home/basant.jain/abc.sh

Basant Jain
  • 115
  • 1
  • 12

1 Answers1

2

Cron doesn't set PATH like your login shell does.

As you already wrote in your question you could specify the full path of snowsql, e.g.

#!/bin/bash
/path/to/snowsql --config /home/basant.jain/snowsql_config.conf \
...

Note: /path/to/snowsql is only an example. Of course you should find out the real path of snowsql, e.g. using type snowsql.

Or you can try to source /etc/profile. Maybe this will set up PATH for calling snowsql.

#!/bin/bash
. /etc/profile
snowsql --config /home/basant.jain/snowsql_config.conf \
...

see How to get CRON to call in the correct PATHs

Bodo
  • 9,287
  • 1
  • 13
  • 29