I try to put a script that sends me a mail, in the crontab of my container (node:18-alpine3.15).
Here are my scripts:
--- Dockerfile
FROM node:18-alpine3.15
COPY node/index.js /home
COPY node/.env /home
COPY node/entrypoint.sh /home
WORKDIR /home
RUN chmod +x /home/entrypoint.sh;apk add --update npm;npm install dotenv;npm install nodemailer;npm install @notionhq/client; /home/entrypoint.sh
ENTRYPOINT ["tail", "-f", "/dev/null"]
---entrypoint.sh
#!/bin/ash
echo "* * * * * cd /home && node index.js" >> /etc/crontabs/root
crond -l 2 -f > /dev/stdout 2> /dev/stderr &
echo "Starting" > /Starting
After starting the container, the directory /Starting exists (so the script was executed).
Also when I display the crontab :
# cat etc/crontabs/root
# do daily/weekly/monthly maintenance
# min hour day month weekday command
*/15 * * * * run-parts /etc/periodic/15min
0 * * * * run-parts /etc/periodic/hourly
0 2 * * * run-parts /etc/periodic/daily
0 3 * * 6 run-parts /etc/periodic/weekly
0 5 1 * * run-parts /etc/periodic/monthly
* * * * * cd /home && node index.js
So my modifications were done, but I don't receive any mail.
But if I decide to run the script by hand :
/home/entrypoint.sh
it works and I get the mail.
Do you have an idea to fix this behavior?