I have installed dirvish for some backups. I have initialized one vault (host). And now I am using the following script to run it:

/sbin/dirvish-expire --quiet && /sbin/dirvish-runall --quiet
exit $rc

The problem is that I cannot find a way to troubleshoot it more. For some reason the second command dirvish-runall --quiet exits with status 1 when it is run as a cron job. When it is in interactive mode it works fine without any issue.

Can you please help?

  • 3
    The difference is almost certainly related to the environment; interactive shells carry a whole lot of environment with them, while cronjobs have a much more minimal one that you largely need to set up by hand. Look to see what environment variables the process is using. – Tom Hunt Sep 8 '15 at 20:56
  • Remove the --quiet flags and rerun with cron. What is the output? – Thomas Erker Sep 8 '15 at 20:56
  • For sure it doesn't use any special variable, also with --quiet it doesn't help a lot because it doesn't print anything valuable. dirvish-runall is a perl script nothing special! I am not sure where should i look next. The output is something like 00:19:01 dirvish --vault test.local 00:19:01 done, nothing more nothing less. – shad0VV Sep 8 '15 at 21:25
  • 1
    Thank you both. @TomHunt you were absolutely correct, i checked thoroughly the perl script and the system call for a binary was not using an absolute path so that was the issue. Thanks a lot! – shad0VV Sep 8 '15 at 21:40

@TomHunt pointed out the problem in his comment, and deserves credit for the answer. I just wanted to expand on his point so that future cron job issues can be resolved more easily.

My suggestion would be to capture your current (functional) environment and also the cron job script's environment, then compare the two to see what's missing. Remember that cron is started at boot-time and never reads any of your personal shell environment files (~/.bashrc, ~/.bash_profile, or anything else loaded from there).

  1. set | sort > /tmp/set.out
  2. Temporarily add set | sort > /tmp/cron-set.out to your cron job's shell script
  3. diff /tmp/cron-set.out /tmp/set.out
  4. Find the environment variable(s) that are missing and add them to your cron job's shell script (while removing the temporary set addition from above).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.