I have set my crontab to run 2 script:
$ crontab -l 0 20 * * * /usr/bin/bkp.sh --silent > /home/perforce/logs/bkp.log 2>&1 0 21 * * * /usr/bin/flsbk.sh --silent > /home/perforce/logs/flsbk.log 2>&1
The first script is not running.
I set up on
crontab -e not
sudo crontab -e
The error I have is this. From
==================================================================================== Starting Backup ==================================================================================== Output location: /home/perforce/output.log Running p4 verify... /usr/bin/bkp.sh: line 22: p4: command not found Done! (No error) Running p4 admin checkpoint... /usr/bin/bkp.sh: line 46: p4: command not found Done! /usr/bin/bkp.sh: line 51: p4: command not found (Error)
And my script is this:
#!/bin/bash echo echo "====================================================================================" echo "Starting Backup" echo "====================================================================================" # Defines output folder and log name OUTPUT_FOLDER='/home/perforce/' OUTPUT_FILE='output.log' OUTPUT=$OUTPUT_FOLDER$OUTPUT_FILE echo "Output location: " $OUTPUT # Creates a temp file TMPFILE=`mktemp` echo -n "Running p4 verify..." # Run the p4 and send the output to the temp file p4 verify -q //... > $TMPFILE echo -n " Done!" # Check if it's empty (no error) # Copy the content to another variable, so we don't mess up with the original output RESULT=`cat $TMPFILE` if [ "$RESULT" != "" ]; then echo " (Error, saving to log)" # Save error on output file `echo $RESULT > $OUTPUT` exit fi echo " (No error)" echo -n "Running p4 admin checkpoint..." # Run the p4 and send the output to the temp file p4 admin checkpoint > $TMPFILE echo -n "Done!" # The file created by the last command COUNTER=`p4 counter journal` FILE=/perforce_depot/checkpoint.$COUNTER # Check if the file was created if [ -f "$FILE" ] then echo " (No error)" else echo " (Error)" exit fi echo -n "Backing up ..." # Finaly, let's create the backup #`cp -r /perforce_depot '/media/perforce/Seagate Backup Plus Drive/perforcebk'` START=$(date +%D) FOLDER_NAME=`echo $START | tr -s '/' | tr '/' '_'` FOLDER_PATH='/media/perforce/BackupDrive/perforcebk' BACKUP_PATH=$FOLDER_PATH/bkp_$FOLDER_NAME mkdir -p $BACKUP_PATH cp -r /perforce_depot $BACKUP_PATH echo " Done!"
p4 is located into
Any one have any idea why i am getting that error? If I ssh to the machine and run manually
sh bhp.sh it runs without a problem and any errors.