You were close, here is the modified Dockerfile that does not give the error and starts cron:
# Add crontab file in the cron directory
ADD crontab /etc/cron.d/hello-cron
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/hello-cron
RUN apt-get update
RUN apt-get -y install cron
# Create the log file to be ...
The problem is not the path to the .7z file, it's the path to the executable 7z
I'm guessing that 7z came from something like HomeBrew, so is not on the default path and your user has a .profile or similar entry that adds directories to the PATH env var.
Use which 7z command to find the full path to 7z and edit the script to use that path.
It looks like you did not provide a full path for $filename and the script is executed by cron with a different working directory than where you tested it.
Can you reformat the script for better readability?
Cron is a little demanding and specific this is how i got to work it on two different ubuntu boxes using two different awscli install methods.
On Ubuntu 16.04 installed via PIP
sudo /home/ubuntu/.local/bin/aws s3 sync --region ap-northeast-1 /var/backups/ s3://BUCKET/backups
On Ubuntu 18.04 installed via apt-get
Run it with user ubuntu, when running with ...
Just experienced the same problem. It seems like it could be related to the actual scanning/loading of the file.
After running "touch /etc/cron.d/smon" (my cron-file) I got the following message in /var/log/syslog:
Sep 3 10:21:01 vm-nca-s1 cron: (systemsmon) RELOAD (/etc/cron.d/smon)
...and now it works.
I finally get it to work, and found the issue with || operator, the script was always returning code 0, so now I've added explicitly a return statement at the end of the script, and now work as expected :
*/1 * * * * (/my/script.sh > /my/file_stdout.log 2>&1) || mail -s "Subject here" firstname.lastname@example.org < /my/file_stdout.log
Assuming you are using Ubuntu and trying to add a cronjob for the root user.
Add this to the top of your shell script export HOME=/root
Ensure when you use any aws command in your script you use the full path, ie. /usr/local/bin/aws s3 cp <from> <to>.
sudo mkdir /root/.aws
sudo cp ~/.aws/credentials /root/.aws/