I know you get this a lot, but i couldn't get this code to work in cron. even though it runs stand alone. i am trying to ssh to server, get last redmine backup file, encrypt it with gpg public key, copy it over to local backup computer, delete encrypted file and exit.
#!/bin/bash
ssh user@192.168.1.131 'cd /data/redmine/redmine/data/backups; file=$(ls -t | head -1); gpg --always-trust --encrypt --recipient 2E87B5C4E322C0AFCD1113EFCBB7C68 $file; enc_file=$(ls *.gpg); scp $enc_file user@192.168.1.129:/backups/redmineBackups/backups; rm $enc_file'
my crontab looks like this
* * * * * /scripts/redmineEncrpt.sh
trying to run it every minute for testing. cron runs it but never get the result.
would you please help me out figure out this? thank you