Scenario: We have a legacy system running FreeBSD 4.7 (please, no laughing. It's being retired at the end of the year.. I just need to keep it alive and backed up until then) and I have some database dump scripts that I run daily with a cron job. I begin the script with #!/usr/local/bin/bash. The script uses the date command to put the date as part of the file name of the dump file. When I run the script manually it works as expected. However, when I put it into a cron job, it fails. I checked my error log and it's failing at the part of the script where I use backticks and the date command for the file name (I also tried $(date...) in the file name and that gave the same error. So I then tried adding /usr/local/bin/bash /path/to/script.sh in the cronjob and it still had the same error.
So my guess is that it's not switching to a bash shell when it runs. I first thought about adding echo $SHELL to my script to see, but I found that switching shells doesn't actually switch the value of the SHELL variable.
Has anyone had a similar issue with FreeBSD? Or does anyone know an alternate way I can check which shell it's using at execution? (I also tried ps >> test.txt and that didn't work in the cron either).
date
executable located in a path that's covered bycron
s$PATH
setting?