Docker Community Forums

Share and learn in the Docker community.

Query regarding R script scheduling with timestamp log file from docker

I am facing issue in scheduling cron job as below from docker file
*/1 * * * * /usr/bin/Rscript /path/script.R >/path//logs/date +\%Y\%m\%d\%H\%M\%S-cron.log 2>&1
The above command generates new log file every minute.

I tried replicating the same from docker file as below

RUN (echo “*/1 * * * * /usr/bin/Rscript /path/script.R > /path/logs/date +\%Y\%m\%d\%H\%M\%S-cron.log”) | crontab -

The above command works , except that only one log file gets generated, with static time stamp.

The new log files get generated if I log in to container and do crontab -e and specify schedule as above.
But issue is if POD restarts, scheduling stops.

Is there a way to specify cron job to generate log files with execution timestamp from docker file itself.