# Ruby in docker container, I have a problem executing script by crontab

**URL:** <https://www.ruby-forum.com/t/ruby-in-docker-container-i-have-a-problem-executing-script-by-crontab/260089>\
**Category:** Uncategorized\
**Created:** [August 2, 2020, 8:09pm UTC](https://www.ruby-forum.com/t/ruby-in-docker-container-i-have-a-problem-executing-script-by-crontab/260089 "2020-08-02T20:09:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![antikurjers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@antikurjers](https://www.ruby-forum.com/u/antikurjers)\
**Post date:** [August 2, 2020, 8:09pm UTC](https://www.ruby-forum.com/t/ruby-in-docker-container-i-have-a-problem-executing-script-by-crontab/260089/1 "2020-08-02T20:09:29Z")

</div>

Hi!  
I made docker:  
Dockerfile:  
FROM ruby:2.7

RUN mkdir /usr/src/app  
WORKDIR /usr/src/app

COPY Gemfile Gemfile.lock ./  
RUN gem install bundler  
RUN bundle install

COPY ./ ./  
RUN chmod +x docker-entrypoint.sh

## CMD [“./docker-entrypoint.sh”]

docker-entrypoint.sh

## #!/bin/sh

echo 'date.local upload script started at: ’ ( date ‘+%F %H:%M:%S’ ) ruby /usr/local/bundle/gems/ckan\_cli-1.0.2/exe/cli.rb upload -d [http://date.local/register.csv](http://date.local/register.csv) -c conf.json -r res.json -w echo 'date.local upload script ended at: ’ ( date ‘+%F %H:%M:%S’ )  
exit 0;

If I start ./docker-entrypoint.sh to do manually in docher bash or from dockerd docker exec -it date.local ./docker-entrypoint.sh script work well. But I need to made crontab job, and one time in day execute this script. I install cron. I made crontab job:  
20 22 \* \* \* /usr/src/app/docker-entrypoint.sh \>\> /var/log/date.local/ `date +\%Y\%m\%d` -date.local.log 2\>&1

But I get the error:  
/usr/src/app/docker-entrypoint.sh: 4: /usr/src/app/docker-entrypoint.sh: ruby: not found

I finded more advice internet, But they not work ☹  
How resolve it?

---

<div class="post-metadata">

**Author:** ![baxang](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/baxang/32/1822_2.png) [@baxang](https://www.ruby-forum.com/u/baxang)\
**Post date:** [August 6, 2020, 8:49am UTC](https://www.ruby-forum.com/t/ruby-in-docker-container-i-have-a-problem-executing-script-by-crontab/260089/2 "2020-08-06T08:49:01Z")

</div>

`docker-entrypoint.sh`'s formatting is broken so it’s a little hard to read - but in cron, the full path of the executable needs to be used.

---

<div class="post-metadata">

**Author:** ![antikurjers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@antikurjers](https://www.ruby-forum.com/u/antikurjers)\
**Post date:** [September 6, 2020, 3:00pm UTC](https://www.ruby-forum.com/t/ruby-in-docker-container-i-have-a-problem-executing-script-by-crontab/260089/3 "2020-09-06T15:00:46Z")

</div>

I redoing docker to docker-compose. And vualla, it worked good.  
As next I redoind to K8s.
