1

I have the following list of tasks to complete and they are working successfully.

0 0 */1 * *  bash /home/user/Code/agapov/start_GHR_Y00011285.sh >> ~/cron.log 2>&1
5 0 */1 * *  bash /home/user/Code/agapov/start_GHR_Y00011280.sh >> ~/cron.log 2>&1
10 0 */1 * *  bash /home/user/Code/agapov/start_GHR_Y10001320.sh >> ~/cron.log 2>&1
20 0 */1 * *  bash /home/user/Code/agapov/aggregation.sh >> ~/cron.log 2>&1
25 0 */1 * *  bash /home/user/Code/ivanov/start_API_N00001010.sh >> ~/cron.log 2>&1

The file structure is as follows:

 #!/bin/bash
 source /home/user/anaconda3/bin/activate
 python /home/user/Code/agapov/GHR_Y00011280.py 
 conda deactivate

But then a problem arises, I added several new files for execution and they do not work. Here is an example of the code for such a file

 #!/bin/bash
 source /home/user/anaconda3/bin/activate
 python /home/user/Code/analyzator.py 
 conda deactivate

As you can see, it is completely similar, the python file itself starts and does its job perfectly, but something goes wrong with the crowns

Cron logs:

/home/user/Code/start_analyzator.sh: line 4: conda: command not found
/home/user/Code/start_analyzator.sh: line 2: /home/user/anaconda3/bin/activate
: No such file or directory
/home/user/Code/start_analyzator.sh: line 3: python: command not found
bash: /home/user/Code/ivanov/start_DS_N00001400.sh: No such file or directory
/home/user/Code/start_analyzator.sh: line 4: conda: command not found
/home/user/Code/start_analyzator.sh: line 2: /home/user/anaconda3/bin/activate
: No such file or directory
/home/user/Code/start_analyzator.sh: line 3: python: command not found
/home/user/Code/start_analyzator.sh: line 4: conda: command not found

analyzator - a file that sends a message to a telegram, here are its settings for checking

*/5 * * * * bash /home/user/Code/start_analyzator.sh >> ~/cron.log 2>&1

What could be the problem, some files work fine and others don't???

8
  • Looks like you need to set the PATH variable in your cron job. Commented Jan 26, 2021 at 15:48
  • Did you create the shell script on a windows machine? Commented Jan 26, 2021 at 15:52
  • @RamanSailopal everything is configured, there were no such problems before, the old settings work successfully. it seems that is not the case Commented Jan 26, 2021 at 15:54
  • @tink Yes, I work through Moba, a computer running Windows 10 Commented Jan 26, 2021 at 15:55
  • 1
    Convert the file to unix line endings ... Commented Jan 26, 2021 at 15:56

1 Answer 1

2

You're suffering from DOS line-endings inside your shell script, the CR gets interpreted as part of the file name, which indeed does not exist.

One way of dealing with this would be to use a linux editor; another way would be to use

dos2unix < infile > outfile
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.