« first day (2657 days earlier)      last day (2288 days later) » 

1:34 AM
@Arcticooling I might not understand Stack Exchange well enough, but it's my understanding that after the 7-day period expires, the bounty will automatically go to the previously-accepted answer (this one), perhaps not achieving your goal. I suppose it gets your question to the "Featured Questions" tab.
 
cas
1:46 AM
@Arcticooling there's an obscure concept called "configuration files". The basic idea is that you put all your configuration variables in one file and then every program that needs them gets them from that file. For shell scripts, just source the config file. DO NOT use a generic file like /etc/bash.bashrc because that may contain other commands that you do not want to execute every time you read some config variables.
also note that variables need to be export-ed if you want external programs as well as the shell to see them. e.g. export foo=bar instead of just foo=bar.
@V.7 nope. not at all.
 
V.7
Roger that, so any information about this question ? 'cause no one answered it yet
 
2:42 AM
@JeffSchaller It's only automatically awarded to answers a) posted after the bounty and b) scoring 2 or higher, unless it's your own question and you accepted the answer. It's needlessly complex
 
 
7 hours later…
9:58 AM
@cas I know what is a config file in general. I just don't want to double declare a variable (once in bash.bashrc/profile and once in cron). Is there no way to export at least just one line with a variable from bash.bashrc or profile --- into all cron "scope"?
 
10:12 AM
@Arcticooling You can source your bashrc from the cron command, for example:
. /path/to/.bashrc && cronCommand
 
cas
except you probably don't want to source .bashrc because it probably does lots of other stuff that is either unnecessary or undesirable when run from a cron job. that's why i said use a different file for such variables, and source it from wherever they're needed.
 
10:32 AM
Yep.
I was thinking . <(grep VARNAME ~/.bashrc) but I'm not sure that would work. It would on systems where cron runs sh (bash) but I would expect it to fail on systems where sh is dash or other minimalist shells.
 
10:43 AM
I felt for a long time like this should be possible (the latter part of my answer):
2
A: how to append lines/text to the beginning of file

WildcardRelatively elegant solution using POSIX specified file editor ex—at least elegant in the sense that this will handle any arbitrary contents rather than depending on a specific format (trailing backslashes) or a specific absence of format. printf '0r headerfile\nx\n' | ex file-with-contents Thi...

 
11:14 AM
Thanks @cas and @terdon. This information helped me much.
 
 
1 hour later…
12:18 PM
You are welcome to review my answer here:
0
A: cron ignores variables defined in ".bashrc" and ".bash_profile"

ArcticoolingThe simplest and safest solution might be to create a "control configuration" file for your work user, and then source it at least from your cron scope: cat <<-"CONTROL" > ~/control.conf drt="/var/www/html" alias rss="/etc/init.d/php*-fpm restart && systemctl restart nginx.service" a...

 
 
6 hours later…
6:05 PM
@MichaelHomer Wow - it sure is; thank you! I think my takeaway is "I may never have Stack Exchange memorized".
 
 
4 hours later…
10:12 PM
how can i merge my unix.stackexchange.com account with all my other stack exchange accounts?
 

« first day (2657 days earlier)      last day (2288 days later) »