ph3nx
ph3nx

Reputation: 1046

Crontab bash script: no such file or directory

A bash script is executed with crontab. For each run the following error is delivered as email:

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

Content in the crontab is as follows:

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

The script works as it should, but the error emails are piling up in the inbox. How can this error be solved?

Upvotes: 5

Views: 14119

Answers (2)

K Donahue
K Donahue

Reputation: 81

The issue occurs when copying and pasting lines between Windows and Linux when doing a crontab -e.

The Windows LF char x'0d' gets inserted and causes issues. The solution is to remove all lines and type them back in. You can spot the issue by doing a crontab -l | od -x and looking for the 0d characters.

Upvotes: 8

ph3nx
ph3nx

Reputation: 1046

To find the line in the script where the error occurs different parts of the script were commented out. The problem occured even when there was only the first line left, containing: #!/bin/bash

The problem was solved by creating a new script and writing the first line from above manually and pasting the remaining content of the old script. We think there were characters in the first line of the script that were not visible in our editor.

Upvotes: 1

Related Questions