Command not running in Linux script under a cron job
Posted on 2016-08-15
I created a script (oracle-copy.sh) that retrieves the most recent ZIP file and then stores the name of it in a variable. After it does that, it runs a "scp" command to copy that ZIP file to a remote server. When I run the script manually, it does the copy just fine, but when I set this script to run under a cron job every day, it seems to fail at the command that retrieves the latest ZIP file name.
This commands retrieves the name: LATESTFILE=$(ls *.zip -t1 | head -n1)
I can tell that it doesn't get the file name because I then run this command and the name is not attached: echo "/data99/backup/$LATESTFILE". It just shows me /data99/backup/ with nothing else.
Thank you in advance,