I have this docker file:
FROM php:7.4-cli COPY . /src/ WORKDIR /src/ CMD [ "php", "./src/index.php" ]
ANd I’m using this two commands to run it:
docker build -t php_script . winpty docker run -it --rm --name my-running-app php_script
How can I receive the output of my script in the text file and not in the terminal and can I automatize the process? For example to start the script everyday in the certain time?
Advertisement
Answer
Run container and write result to a file:
winpty docker run -it --rm --name my-running-app php_script >> /path/to/filename.txt
For the daily task create a cronjob cronjob -e
and add line like:
# every day at 01.00 AM 0 1 * * * winpty docker run -it --rm --name my-running-app php_script >> /path/to/filename.txt