1
votes

I want to schedule a shell script to will run every hour. For that I was trying to schedule from cron on acquia server.

The shell script file is in "docroot/scripts/script_name.sh". In Command option I gave command as "/var/www/html/pllsrv2313.dev/scripts/script_name.sh", but it is not working.

2
Can you provide your shell script? Without a look at the code then there's no way for us to know what's not working. Are you able to get the script to work locally or on the Acquia server? SSH to your acquia server and run the command "sh /path/to/shell/script.sh" to see if it works if you execute it directly. Here is additional documentation on the use of shell scripts in cron jobs: docs.acquia.com/cloud/manage/cron#example - ScottA

2 Answers

1
votes

I think that the shell script file should be in "scripts/script_name.sh".

If you are calling a php script from the shell file, you need to use the whole path to the php file even if it is in the same directory.

0
votes

First start with logging into your box:

Then like @ScottA mentioned call your script: This time do it with verbose flag which is -x.

sh -x /var/www/html/pllsrv2313.dev/scripts/script_name.sh

This is going to dump out everything your script runs or error out. See if anything is not what you expected.

In my case Inside my script I had a curl request that was not going through as planned:

curl --silent --compressed http://dev.example.com/code.sh

So I flagged my curl call --verbose to get that to dump as well:

curl --silent --compressed --verbose http://dev.example.com/ 

and called:

sh -x /var/www/html/example.dev/docroot/ex_scripts/my_script.sh

I got back that the host could not be resolved because my dev domain was only available inside my DNS. So for me the problem is when cron runs my curl fails do to my non public accessible dev domain.

...
+ curl --silent --compressed --verbose http://dev.example.com/
* getaddrinfo(3) failed for dev.example.com:80
* Couldn't resolve host 'dev.example.com'
* Closing connection #0
...