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,798

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,798