I am trying to a run a cronjob on my Windows machine with Cygwin that needs access to environment variables that I have defined in my ~/.bashrc. Here all the different things I have tried to get it to access the env variable:
- Simple sourcing of bashrc
PATH=/bin:/usr/bin:/usr/local/bin:$PATH
SHELL=/usr/bin/bash
*/1 * * * * source ~/.bashrc ; env | grep "MAP60"
- Invoking bash and running the command
PATH=/bin:/usr/bin:/usr/local/bin:$PATH
SHELL=/usr/bin/bash
*/1 * * * * /usr/bin/bash -c "source ~/.bashrc ; env | grep MAP60"
- Trying a bash login shell
PATH=/bin:/usr/bin:/usr/local/bin:$PATH
SHELL=/usr/bin/bash
*/1 * * * * /usr/bin/bash -lc " source ~/.bashrc ; env | grep MAP60"
None of these work, but case 3 works if I add the variable to my ~/.bash_profile. I have also tried sourcing the bashrc with the full path, and also using . instead of source to invoke the file. I've also tried just sourcing the bash_profile directly like in case 1, but that doesn't work either. I would like to have the variables be called in the ~/.bashrc rather than having to call a login shell each time. How can I achieve that with cygwin cron?
/usr/bin/bash -lc " set -x; source ~/.bashrc ; env | grep MAP60" 2>/tmp.error.log- Gordon Davisson