1

This question already has an answer here:

This is related to one of the questions posted already!

I was trying to run one of the scripts (for example, wrapper.sh) which internally executes other scripts using crontab. It works fine without any issues.

When i have created a environment file (which stores the passwords-DB and paths) and trying to execute the main script (wrapper.sh) the cron entry doesn't work on those scripts which are called internally in the wrapper.

NOTE:
I tried changing PATH, added env file location before the script in cron but it still didn't work:

9 9 * * * . /$SOMEPATH/some.env; /$SOMEPATH/wrapper.sh

The environment script and wrapper.sh are in same path. when the cron runs it passes the env variables to wrapper but not to the scripts which are called internally in wrapper. Also a mail is received on /var/mail/$user saying the env file as "No such file or Directory". I've gone through many posts but couldn't figure out the resolution.

marked as duplicate by Kiwy, JdeBP, peterh, muru, Toby Speight Dec 13 '17 at 11:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • If you tries to get a correct answer, please, could you explain us with an example what is the goal of what your doing, how you do it, and what's not working as expected. For me your issue rely more on environement variable but can't be sure as you dont show us your script and don't explain what's not working. Please consult the unix.stackexchange.com/tour before posting ;-) – Kiwy Dec 13 '17 at 9:45
  • Why don't you source the file with the environment variables from within the script itself? Also, is the / in front of $SOMEPATH a typo? – Kusalananda Dec 13 '17 at 9:45
  • @JdeBP Yes, You are right. This is the same question, In the previous post I was unable to edit or comment the question. So created a new thread. Already mentioned the same and Sorry for the trouble. – user265629 Dec 13 '17 at 10:15
  • @user265629, oh that's even worse than I thought. I hope you still have access to the email you used for the first account: unix.stackexchange.com/help/reset-password also unix.stackexchange.com/help/merging-accounts – ilkkachu Dec 13 '17 at 10:18
  • @ilkkachu I entered as a guest and i didn't gave any password while posting the question. I am sorry for doing it. Please ignore the last post. – user265629 Dec 13 '17 at 10:21