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 [email protected] '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 [email protected]:/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
my issue is just a typo, filename was wrong. thanks to Barmer who helped me output cron log that let to fixing the problem
thanks guys