crontab定时执行shell脚本失败
解决办法
要定时执行的shell脚本开头引入你自己有访问权限的环境变量文件:
#!/bin/sh
. /home/hsy/.profile(这是Ubuntu的,如果是CentOS就改成bash_profile)
. /home/hsy/.bashrc
# 以下写你脚本的内容
crontab -e要这么写:
0 8 * * 1-5 . /home/hsy/.profile;/bin/sh /path/to/your/shell.sh
#!/bin/sh
. /home/hsy/.profile(这是Ubuntu的,如果是CentOS就改成bash_profile)
. /home/hsy/.bashrc
# 以下写你脚本的内容
0 8 * * 1-5 . /home/hsy/.profile;/bin/sh /path/to/your/shell.sh