我有一个从交互式shell运行良好的crontab脚本。 但是,从crontab运行时,它会失败,因为它不运行/etc/profile.d/中的脚本(例如/etc/profile.d/java.sh)
什么是解决这个问题的最好方法?
用以下命令启动shell脚本:
#!/bin/bash -l
这导致bash作为loginshell启动,这意味着它将读取/ etc / profile和〜/ .bash_profile。
在你的crontab上设置SHELL:
SHELL=/bin/bash * * * * * # your_job