On my FreeBSD server, I have setup a cron script for backups using Duplicity. This script is as follows:
#!/bin/sh
export PASSPHRASE=
export FTP_PASSWORD=
keyid=
remote=
excludelist=
/usr/local/bin/duplicity --volsize 1000 --max-blocksize=20480 --asynchronous-upload --full-if-older-than 1M --encrypt-key "$keyid" --exclude-filelist "$excludelist" /Data "$remote"
/usr/local/bin/duplicity --force remove-all-but-n-full 1 "$remote"
unset FTP_PASSWORD
unset PASSPHRASE
(sensitive data redacted, of course).
This script is located at /etc/periodic/daily/duplicity and works fine if I run it directly from the terminal. But it doesn't work when cron/periodic runs it, and that seems te be because env
is not functioning correctly.
Initially, the hashbang of the script read #!/usr/bin/env sh
, but that resulted in the error env: sh: No such file or directory
. So I changed it to the direct path of sh.
The problem I'm currently having is that duplicity uses env
internally. So currently, I get the error env: python2: No such file or directory
when cron tries to run it.
Why doesn't env
work inside cronjobs, and how can I fix this?