organic-search-analytics
organic-search-analytics copied to clipboard
CRON Job Executes but Data Isn't Updated
I am using the multiple domain method listed here: https://github.com/PromInc/organic-search-analytics/wiki/CRON
Using CPANEL I specify the path to a shell script with the command. This allows me to use the php modifier #!/usr/bin/php, with otherwise cause an error.
The script executes with no errors reported, but the reporting and data capture front ends aren't updated, nor is data retrieved. Any hints as to how we can troubleshoot / resolve this issue?
Thanks!
Here is the script code:
#!/usr/bin/php
for DOMAIN in http://acuteservices.com/ http://grahams.ca/; do /home/profitwo/searchanalytics.profitworks.ca/data-capture-run.php googleSearchAnalytics $DOMAIN date --date='5 days ago' '+\%Y-\%m-\%d'; done;
I am running it from a CPANEL scheduler as attached

Your script start with #!/usr/bin/php which means the script is expecting PHP code. However the code you've put into the script is in the BASH language.
I'm assuming you are declaring PHP because cpanel won't allow you to run a shell/BASH script.
For those reasons, I'd try this.
- Change your scripts file name from
capture.shtocapture.php - Adjust your CPANEL scheduler to point to this new file
- Change your script to PHP. I believe this code will work, but it is untested:
#!/usr/bin/php
<?php
$DOMAINS = array( "http://acuteservices.com/", "http://grahams.ca/" );
foreach( $DOMAINS as $DOMAIN ) {
file_get_contents( 'http://urltoyourproject.com/data-capture-run.php?type=googleSearchAnalytics&domain=' . $DOMAIN . '&date=' . date( 'Y-m-d', strtotime('-5 day') ) );
}
?>
I don't run CPANEL under the configuration you are so I'm not able to fully test this setup. But I believe this should put you down the right path.
Please comment back with your final setup so as to help others in the future.
Thanks for the input I really appreciate it.
I'll need to debug the code but currently when I run it in terminal it doesn't seem to output anything. Can you confirm that the url argument should be a fully qualified url versus the server directory (i.e. http://url.com/data-capture.run.php vs /home/directory/data-capture.run.php?
Yes it should be a fully qualified URL.
The PHP function file_get_contents can call a URL, and given how the data-capture.run.php file sets up some variables/resources it relies on the webserver to process the request.