I recently got a new DigitalOcean LEMP environment with Ubuntu. I tried making an SH script that uses CasperJS to scrape data from an external website to a JSON file, and a PHP script to parse the JSON and update a MySQL database. The SH is executed by a cron job. My crontab is as follows, meant to run every 90 minutes.
# m h dom mon dow command 0 0,3,6,9,12,15,18,21 * * * /bin/sh /usr/share/nginx/private/mpd_calls_for_service/scrape_mpd_calls_cron.sh 30 1,4,7,10,13,16,19,22 * * * /bin/sh /usr/share/nginx/private/mpd_calls_for_service/scrape_mpd_calls_cron.sh
And the SH file in question is.
#!/bin/sh /usr/local/bin/casperjs /usr/share/nginx/private/mpd_calls_for_service/scrape_mpd_calls.js /usr/bin/php /usr/share/nginx/private/mpd_calls_for_service/parse_json_file.php
Executing these lines of code individually via Terminal in SSH works fine. However, when running the shell script manually via SSH, or the Cron, this is the result.
Could not open input file: /usr/share/nginx/private/mpd_calls_for_service/parse_json_file.php
The solutions I have tried over the past two days have included
- CHMOD 777 for all affected files.
- Editing the crontab-e while sudo.
- Reinstalling PhantomJS and CasperJS via npm -g.
After multiple attempts though, I'm at a dead end and ready to start pulling my hair out. Any assistance from the community would be appreciated.