New answers tagged

0

You were close, here is the modified Dockerfile that does not give the error and starts cron: FROM python:3.6.9 # 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 #Install Cron RUN apt-get update RUN apt-get -y install cron # Create the log file to be ...


0

Put the full path on the 7z command. The problem you're having is that cronjob doesn't have the same PATH as your shell. You can find the full path of the 7z with command -v 7z command.


0

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.


1

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?


0

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 ...


2

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[994]: (systemsmon) RELOAD (/etc/cron.d/smon) ...and now it works.


0

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" my.email@address.com < /my/file_stdout.log


0

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/


Top 50 recent answers are included