我有一个运行脚本的 cron 作业。当我通过交互式 shell(ssh 到 bash)运行脚本时,它工作正常。当脚本通过 cron 自行运行时,它会失败。
我的猜测是它使用了交互式 shell 中设置的一些环境变量。我将对脚本进行故障排除并删除它们。
进行更改后,我知道我可以在 cron 中将脚本排队以使其正常运行,但是有没有一种方法可以从命令行运行脚本,但告诉它像从 cron 一样运行 -即在非交互式环境中?
shell cron environment-variables interactive
cron ×1
environment-variables ×1
interactive ×1
shell ×1