16

Works just fine when running it manually on the shell but when I setup a cronjob to run it on reboot I get "bad 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
steros
  • 1,452
  • 1
  • 18
  • 54

2 Answers2

26

There is a space between the #! and the /bin/sh. I don't think this is the reported problem but it needs fixing *

I guess that you are using a version of Unix or Linux where /bin/sh is not bash so the export syntax is wrong.

Alter your script to say

PASSPHRASE=foo
export PASSPHRASE

See this answer UNIX export command

* it's not a problem, see comments

Vorsprung
  • 28,957
  • 4
  • 32
  • 55
2

They way you export or set your variables are incompatible with your shell. When executing the script - try and use different shell.

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

Mostly bash will work for you.

Muthuveerappan
  • 106
  • 1
  • 3
  • 12