Timeline for Can't use `source` from cron?
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 14, 2017 at 14:21 | comment | added | terdon♦ |
@PhilipKirkbride they are set, but are they exported? That's a big difference. That you can see the variable when you echo it doesn't mean that child processes inherit it. Compare foo='bar'; bash -c 'echo $foo' and export foo='bar'; bash -c 'echo $foo' to see what I mean.
|
|
| Oct 14, 2017 at 14:04 | vote | accept | Philip Kirkbride | ||
| Oct 14, 2017 at 14:04 | comment | added | Philip Kirkbride |
The issue is actually that despite my environment variables being set, (I switched the aws command to echo $AWS_DEFAULT_REGION >> /test to confirm), awscli doesn't seem to see them. Though normally it works in the main terminal of Docker and recommends authenticating via environment variables docs.aws.amazon.com/cli/latest/userguide/cli-environment.html The problem is out of the scope of this question, so I will mark as solved and maybe post something on their github.
|
|
| Oct 14, 2017 at 14:03 | comment | added | terdon♦ |
@PhilipKirkbride I know, but I wanted to explain why & will always be wrong here.
|
|
| Oct 14, 2017 at 14:02 | comment | added | Philip Kirkbride | sorry I spoke too soon and deleted my comment right after | |
| Oct 14, 2017 at 14:01 | comment | added | terdon♦ |
@PhilipKirkbride if && breaks, that means the source failed yes. Most likely because you're not using bash so you need to do .. But running . file & (sourcing in the background) will never work because backgrounded commands run in their own subshell, so the variables you sourced will only be available there. If you want to run the second command even if the first failed, use ;, but don't use & here.
|
|
| Oct 14, 2017 at 13:54 | comment | added | terdon♦ |
@PhilipKirkbride if you mean the first one with root /usr/bin/env bash &, then that won't work, no. You're just sending a bash instance to the background. If the second one also fails, please explain exactly how it fails since "doesn't work" isn't very informative.
|
|
| Oct 14, 2017 at 13:53 | comment | added | Philip Kirkbride | I tried your original and suggestion and it didn't work. I'm going to re-build with your update and see if that works. | |
| Oct 14, 2017 at 13:52 | history | edited | terdon♦ | CC BY-SA 3.0 |
added 1 character in body
|
| Oct 14, 2017 at 13:46 | history | answered | terdon♦ | CC BY-SA 3.0 |