6

Many have said that the problem is with environment but I still can't seem to solve this problem. BTW I am using Ubuntu 9.10 login as user, then sudo -s using this command: s3cmd put file s3://bucket >>worked! now here is the simple script intended for testing:

#! /bin/bash
env >/tmp/cronjob.log

s3cmd put file s3://bucket

issuing the command crontab -e

* * * * * /opt/script  2>&1 | logger

Then using tail to syslogs

Dec 3 23:22:01 ubuntu CRON[10795]: (root) CMD (/opt/script 2>&1 | logger)

But by verifying it on s3Fox Organizer, the file is not uploaded.

(I tried changing the #! /bin/sh (no effect), putting crons on /etc/crontab (no effect), setting HOME=/home/user (no effect)

What are other options to try? Or other ways to debug this problem.

Thanks

1
  • I also tried this /usr/local/bin/s3cmd put file s3://bucket (still no effect)
    – Jonar
    Dec 3, 2010 at 15:26

7 Answers 7

4

I had the same problem. In my case it was missing configuration file (different env variables):

s3cmd -c /root/.s3cfg --no-progress -v put $TODAY_FILE $BUCKET  2>&1

If you will invoke your command like:

s3cmd command options 2>&1 | logger

You should be able to see in the logs real problem.

4

What worked for me was to make sure HOME is set to the correct path. If you can run the command under user joe then your script should look like this:

HOME=/home/joe
s3cmd ...
2

Change

s3cmd put file s3://bucket

to

s3cmd put file s3://bucket > /tmp/s3cmd.log

That way you can see what kind of problem s3cmd is having.

2

Make sure you are referencing s3cmd using its full path (/usr/bin/s3cmd) in your script. Check that you have run s3cmd --configure as the user that cron will be running under, generally root.

2

cron runs under root user, make sure your root user has s3cmd configuration otherwise copy them for root user

cp -i /home/ubuntu/.s3cfg /root/.s3cfg

0

Check that $HOME/.s3cfg contains the access key and secret code for s3. If not, s3cmd will try to fetch them from the env variables which is different during cron session.

0

i had the same problem and i tried to figure out why it is not running. My solution was to add the following lines to the top of my script:

export HOME=/home/$USERNAME cd /home/$USERNAME

Also you should call the s3cmd with:

/usr/bin/s3cmd

OR put the following line to the top of your script:

PATH=$PATH:/usr/bin

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .