从 cron 选项卡中找不到 snowsql
snowsql not found from cron tab
我正在尝试从我用 cron 作业安排的 shell 脚本执行 snowsql。但是我收到类似 snowsql 的错误:找不到命令。
我浏览了很多链接,他们要求我们提供雪花的完整路径。我也尝试过但没有运气。
https://support.snowflake.net/s/question/0D50Z00007ZBOZnSAP/snowsql-through-shell-script。下面是我的代码片段 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'
我的 crontab 如下所示:
*/1 * * * * /home/basant.jain/abc.sh
Cron 不会像您的登录 shell 那样设置 PATH
。
正如您在问题中所写,您可以指定 snowsql
的完整路径,例如
#!/bin/bash
/path/to/snowsql --config /home/basant.jain/snowsql_config.conf \
...
注意:/path/to/snowsql
只是一个例子。当然你应该找出 snowsql
的真实路径,例如使用 type snowsql
.
或者您可以尝试来源 /etc/profile
。也许这会设置 PATH
来调用 snowsql
.
#!/bin/bash
. /etc/profile
snowsql --config /home/basant.jain/snowsql_config.conf \
...
见How to get CRON to call in the correct PATHs
我正在尝试从我用 cron 作业安排的 shell 脚本执行 snowsql。但是我收到类似 snowsql 的错误:找不到命令。
我浏览了很多链接,他们要求我们提供雪花的完整路径。我也尝试过但没有运气。 https://support.snowflake.net/s/question/0D50Z00007ZBOZnSAP/snowsql-through-shell-script。下面是我的代码片段 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'
我的 crontab 如下所示:
*/1 * * * * /home/basant.jain/abc.sh
Cron 不会像您的登录 shell 那样设置 PATH
。
正如您在问题中所写,您可以指定 snowsql
的完整路径,例如
#!/bin/bash
/path/to/snowsql --config /home/basant.jain/snowsql_config.conf \
...
注意:/path/to/snowsql
只是一个例子。当然你应该找出 snowsql
的真实路径,例如使用 type snowsql
.
或者您可以尝试来源 /etc/profile
。也许这会设置 PATH
来调用 snowsql
.
#!/bin/bash
. /etc/profile
snowsql --config /home/basant.jain/snowsql_config.conf \
...
见How to get CRON to call in the correct PATHs