0

I have this ultra simple cron job:

48 20 * * * cd /home/pankaj;s3cmd -f get s3://myfile.gz

The command works by itself. But the cron job does not. The cron job is created for the same user(pankaj) who is able to run the command. There is not much information in /var/log/syslog either.

Oct 15 20:48:01 dev CRON[17020]: (pankaj) CMD (cd /home/pankaj;s3cmd -f get s3://myfile.gz)
Oct 15 20:48:01 dev CRON[17019]: (CRON) info (No MTA installed, discarding output)

How can I find out what is going wrong? The permissions of .s3cfg are like these:

pankaj@dev:~$ ls -l .s3cfg 
-rw------- 1 pankaj pankaj 2050 Feb  7  2018 .s3cfg
3
  • 1
    The first step would be to get a look at the output! Try installing a mail server, or redirecting stdout/stderr. Have you tried running the command without a PTY?
    – Attie
    Commented Oct 15, 2020 at 15:44
  • 1
    Where you have this s3cmd script? Try to use absolute path to this script and add option to point to the config file ;) I think you setup this cron job on root account but .s3cfg file is in pankaj HOMEDIR.
    – mariaczi
    Commented Oct 15, 2020 at 15:52
  • Thanks Attie and mariaczi. Your hints helped
    – kargirwar
    Commented Oct 15, 2020 at 16:08

1 Answer 1

0

Modified the cronjob to this:

48 20 * * * cd /home/pankaj;s3cmd -f get s3://myfile.gz 2>&1 | tee log

And log showed this:

s3cmd: command not found

:(. So a simple change solved the problem:

48 20 * * * cd /home/pankaj;/usr/local/bin/s3cmd -f get s3://myfile.gz

You must log in to answer this question.

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