0

I am using aws lightsail product.

When i execute on bash the commend,

* * * * * docker exec -it my_container_name Rscript /home/path/to/file.R

I also checked cron log using

grep CRON /var/log/syslog

and it says it worked fine. But the result is not given.

asbebe
  • 71
  • 1
  • 11

2 Answers2

1

Why run -it ?

Would it not be better to place the script in the container and run -d ?

Does the

Additional to that, your bash-env may be set up differently if you use cron rather than interactive login. PATHS , LC setting have caused me most issues.

Tim Seed
  • 5,119
  • 2
  • 30
  • 26
0

Does your dockerimage file have an ENTRYPOINT

i.e.

copy run2.sh /usr/local/bin/run2.sh
run chmod +x /usr/local/bin/run2.sh
ENTRYPOINT ["/usr/local/bin/run2.sh"]

Your run2.sh file should look something like this (so it can respond to Signals from the OS i.e. shutdown)

#!/bin/bash
#This is a run file - which should be used to add things you want your
#container to do when you start it up
#
#If you do not have this then ...
#  docker-compose up ---- simply exists as there is nothing for the container to do.

trap cleanup 1 2 3 6 9 15

cleanup()
{
  echo "Caught Signal ... cleaning up."
  service postgresql stop
  sleep 1s
  echo "Done  ... quitting."
  exit 1
}

service postgresql start
# wait forever
echo "Starting up"
while true
do
  tail -f /dev/null
done

Note: This removes the necessity to start services, plus you get to specify the shutdown steps required.

If you want you can have multiple rules, I was just lazy and lobbed them all together.

Hope this helps....

Tim Seed
  • 5,119
  • 2
  • 30
  • 26