Crontab bash 脚本:没有那个文件或目录
Crontab bash script: no such file or directory
一个bash脚本是用crontab执行的。对于每个 运行,以下错误将作为电子邮件发送:
/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)
脚本正常运行,但收件箱中堆积了错误电子邮件。这个错误如何解决?
要找到脚本中发生错误的行,脚本的不同部分已被注释掉。即使只剩下第一行时也会出现问题,其中包含:
#!/bin/bash
问题已通过创建新脚本并手动编写上面的第一行并粘贴旧脚本的剩余内容来解决。我们认为脚本第一行中的某些字符在我们的编辑器中不可见。
执行 crontab -e
时在 Windows 和 Linux 之间复制和粘贴行时会出现此问题。
Windows LF
char x'0d'
被插入并导致问题。解决方案是删除所有行并将它们重新输入。您可以通过执行 crontab -l | od -x
并查找 0d
字符来发现问题。
一个bash脚本是用crontab执行的。对于每个 运行,以下错误将作为电子邮件发送:
/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)
脚本正常运行,但收件箱中堆积了错误电子邮件。这个错误如何解决?
要找到脚本中发生错误的行,脚本的不同部分已被注释掉。即使只剩下第一行时也会出现问题,其中包含:
#!/bin/bash
问题已通过创建新脚本并手动编写上面的第一行并粘贴旧脚本的剩余内容来解决。我们认为脚本第一行中的某些字符在我们的编辑器中不可见。
执行 crontab -e
时在 Windows 和 Linux 之间复制和粘贴行时会出现此问题。
Windows LF
char x'0d'
被插入并导致问题。解决方案是删除所有行并将它们重新输入。您可以通过执行 crontab -l | od -x
并查找 0d
字符来发现问题。