1

Set-up

I have 3 .txt files containing commands to be executed each day.

The berlin_run.txt file executes a.o. the 2 other .txt files. The file is the following,

#!/bin/bash

cd /path/to/folder/containing/berlin_run.txt
PATH=$PATH:/usr/local/bin
export PATH

./spider_apartments_run.txt
./spider_rooms_run.txt
python berlin_apartments_ads.py;python berlin_rooms.py

When I cd to /path/to/folder/containing/berlin_run.txt in my MacOS Terminal, and execute the ./berlin_run.txt command, everything works fine.

It is my understanding that ./ opens the berlin_run.txt, and that #!/bin/bash ensures that the subsequent lines in the berlin_run.txt are automatically executed upon opening.


Problem

I want to automate the execution of berlin_run.txt.

I have written the following cronjob,

10 13 * * * /path/to/folder/containing/berlin_run.txt

It is my understanding that this cronjob should open the berlin_run.txt each day at 13:10. Assuming that is correct, #!/bin/bash should execute all the subsequent lines. But nothing seems to happen.

Where and what am I doing wrong here?

LucSpan
  • 1,831
  • 6
  • 31
  • 66
  • is python in /usr/local/bin? or inside folders in PATH? – Lino Apr 14 '18 at 11:01
  • Not sure how I figure that out? Does it make a difference if it is/isn't? The code works fine when executed manually via Terminal. – LucSpan Apr 14 '18 at 11:09
  • `which python` is the command that let's you know where it is located. – Lino Apr 14 '18 at 11:15
  • just add `echo $PATH > /Users/youraccountname/path.txt` after `export PATH` in your script and see all the folders in the path. Now verify that the folder containing python is in the path.txt file – Lino Apr 14 '18 at 11:20
  • https://stackoverflow.com/a/49296678/1135424 to help debug your cron – nbari Apr 14 '18 at 11:24
  • @Lino, if done the `which python` which shows `/Applications/anaconda/bin/python`. What should I do now? – LucSpan Apr 14 '18 at 12:27
  • Typically, a file containing a shell script would have a `.sh` extension. – glenn jackman Apr 14 '18 at 13:48

0 Answers0