1

I am trying to run a script from /var/www/backups/scripts and when i try tell it to zip up a file i get the below error,

I can confirm that /var/www is the home dir and that the scripts work when ran manually though putty but just not though a script.

I'm using the below code to run the zip

#!/bin/bash
unset PATH

#USER VARS

HOMEDIR=~/
BACKUP_TARG_DIR=~/sites/backups/auto
BACKUP_TEMP_NAME=tempBackupFile.tar
BACKUP_TARG_FILE=/var/www/back
DATE=`/bin/date '+%Y-%m-%d'`


echo  `/bin/pwd`;

tar -zcvf test.rar /var/www/backups/scripts/tryThis

#cd /var/www
#scp "tempBackupFile.tar" 217.41.51.14:~/testfile.rar;
#tar -zcvf $BACKUP_TEMP_NAME $BACKUP_TARG_FILE;
echo "SITE-"$DATE;

below is the output i get

/var/www/backups/scripts
./autoBackup.bash: line 18: tar: No such file or directory
SITE-2011-09-05

Any one have any ideas as this is killing me, all I can think of is its something to do with where the bash script is being run from.

2
  • Are you running the backup script as the same user when invoking from putty or from another script? Commented Sep 5, 2011 at 12:10
  • Seems like tar is not installed? Commented Sep 5, 2011 at 12:13

2 Answers 2

10

Why do you unset PATH ?? No wonder bash cannot execute tar.

Sign up to request clarification or add additional context in comments.

2 Comments

If you unset PATH, you should use the whole complete path to tar when you want to call it.
I copied it from a tutorial, this is my first time doing this. I got it working using /bin/tar, but yes, you are correct; removing the unset PATH has worked. Spent hours on this.
1

Check your /etc/ssh/sshd_config to make sure that you don't have a chroot directory set. If you do, you will need to either create a bin directory in the chroot directory and either copy or link the necessary binaries into that directory.

Or you could always comment that line out in the config.

Either way, restart sshd and test.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.