解决手动运行脚本执行正常而放入crontab后不正常的方法
文章目录
解决需要 导入环境变量
有两种导入方法:
在crontab -e编辑时加入
. /etc/profile;/bin/sh #主要"."后要有个空格
0 12 * * * . /etc/profile;/bin/sh /your/sh/your_sh.sh
在你要运行的脚本的开头加入
source /etc/profile
解决需要 导入环境变量
有两种导入方法:
在crontab -e编辑时加入
. /etc/profile;/bin/sh #主要"."后要有个空格
0 12 * * * . /etc/profile;/bin/sh /your/sh/your_sh.sh
在你要运行的脚本的开头加入
source /etc/profile
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论