In Ubuntu 16.04 Bash 4.3.46(1) at the end of /etc/bash.bashrc
I declared the following variable:
drt="/var/www/html"
I sourced the file (source /etc/bash.bashrc
)
I executed crontab -e
and added just for testing * * * * * touch /var/www/html/myFile.sh
. This worked, while * * * * * touch ${drt}/myFile.sh
didn't.
If a variable declared in bash.bashrc
is global why it doesn't get processed by crontab
?
Update1
I don't want to duplicate the stream drt="/var/www/html"
into crontab
(or cron.d
) to avoid redundancy by principle.
Update2
I followed this session and it seems the answer marked as correct didn't solve my problem.
The second answer was somewhat unclear to me - why to put this conditional statement in (some?) bashrc
file.
I also tried the third solution in relation to bash.bashrc
(added SHELL=/bin/bash
into the very start of crontab
, saved the file and sourced bash.bashrc
but had no change in a * * * * * touch ~/myfiile
test.
I thus ask to reopen this question, or at least, clarify one the answers there.