crontab bash脚本:没有这样的文件或目录



用crontab执行一个bash脚本。对于每次运行,以下错误作为电子邮件交付:

/opt/Informatica/pcdev/scripts/startworkflow_trg.sh: line 1: #!/bin/bash: No such file or directory

crontab中的内容如下:

# Check queue and start corresponding processes in test
* * * * * (. ~/.bash_profile; $HOME/scripts/startworkflow_trg.sh tst)

脚本应尽其所能,但是错误电子邮件在收件箱中堆积。该错误如何解决?

在执行crontab -e时在Windows和Linux之间复制和粘贴线时,问题发生。

Windows LF CHAR x'0d'被插入并引起问题。解决方案是删除所有行并将其重新输入。您可以通过执行crontab -l | od -x并寻找0d字符来发现问题。

在脚本中找到错误发生的脚本不同部分的行。即使只剩下第一行,也会发生问题,其中包含: #!/bin/bash

通过创建新脚本并从上方编写第一行并粘贴旧脚本的剩余内容来解决问题。我们认为脚本的第一行中有字符在我们的编辑中不可见。

最新更新