"bad variable name" in a bash script started by cron

Works fine when run manually in a shell, but when I configure the cronjob to run on reboot, I get a "wrong variable name".

#! /bin/sh
# /etc/init.d/duplicityCleanUp
export PASSPHRASE=foo
duplicity remove-older-than 30D --force --gio smb://remote/archiv/
duplicity remove-all-but-n-full 1 --force --gio smb://remote/archiv/
unset PASSPHRASE

      

+6


source to share


2 answers


There is a space between #!

and /bin/sh

. I don't think this is the reported issue, but it needs fixing.

I am assuming you are using a Unix or Linux version where there is /bin/sh

no bash, so the export syntax is incorrect.

Change your script to say



PASSPHRASE=foo
export PASSPHRASE

      

See this answer UNIX export command

+13


source


The way you export or set variables is incompatible with your shell. When executing the script - try using a different shell.

sh yourscript.sh 
bash yourscript.sh 
ksh yourscript.sh
csh yourscript.sh
zsh yourscript.sh 

      



Mostly Bash will work for you.

0


source







All Articles