2

I have a problem with a cron job which starts but doesn't complete. Running the command manually works fine. I already read the page about cron issues and solutions here on AskUbuntu, tried the proposed solutions but didn't find an answer working in my case.

I'm using Ubuntu 12.04.

$ crontab -e

SHELL=/bin/bash # otherwise it would be /bin/sh
59 16 * * * /bin/duply calendar backup > /tmp/duply.log

Btw, the cron file ends with an empty line, as someone pointed out.

Once the job has "finished"...:

$ cat /tmp/duply.log 
Start duply v1.5.7, time is 2012-06-22 16:59:01.

Instead, running manually the script it works correctly and gives this output:

Start duply v1.5.7, time is 2012-06-22 17:06:39.

[cut]
... here is a long output generated by duply.
... and yes, files have been backed up.
[cut]

--- Finished state OK at 17:06:42.581 - Runtime 00:00:03.170 ---

I also tried to restart the cron daemon (sudo service cron restart) but nothing changed.

Do you have any suggestion to fix the issue?

Paolo
  • 1,776
  • use the error output /bin/duply calendar backup > /tmp/duply.log >> /tmp/duply.error.log and post to see the something error – richie-torres Jun 22 '12 at 15:34
  • now /tmp/duply.log is empty, while /tmp/duply.error.log contains: Start duply v1.5.7, time is 2012-06-22 18:02:01. – Paolo Jun 22 '12 at 16:06
  • 1
    so sorry, this is no the syntax for output error! , is /bin/duply calendar backup > /tmp/duply.log 2> /tmp/duply.error.log ,maybe in file contains duply.error.log some information of crash depends of duply – richie-torres Jun 23 '12 at 00:45
  • Thanks Andrés, fixed. The error file said: duplicity missing. installed und available in path?. So I added to the cron file the same PATH value I have in shell session and the issue disappeared. I didn't think it was required to add PATH to the crontab file because PATH during the cron job is /usr/bin:/bin, and duply resides in /bin. – Paolo Jun 23 '12 at 07:10
  • Now the crontab file starts with: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games. PS: would you mind to add your investigation approach to the wiki page I pointed out in my question, and maybe convert your comment to an answer here? I'd like to upvote for your help. – Paolo Jun 23 '12 at 07:12
  • here o in the other question ? – richie-torres Jun 24 '12 at 23:57
  • I would say this is a trick that in the other question (wiki page) fits better. – Paolo Jun 25 '12 at 00:11

1 Answers1

1

So, based on the comments, follows the answer to my own question.

Error log

A useful (essential) first step was to get an error log.

The syntax to obtain one is:

/bin/duply calendar backup > /tmp/duply.log 2> /tmp/duply.error.log

Cause

Luckily the log files pointed out why:

duplicity missing. installed und available in path?

So I added to the cron file the same PATH value I have in shell session and the issue disappeared. I didn't think it was required to add PATH to the crontab file because PATH during the cron job is /usr/bin:/bin, and duply resides in /bin.

Now the crontab file starts with:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin‌​:/bin:/usr/games
Paolo
  • 1,776