Quantcast
Channel: cron ignores variables defined in ".bashrc" and ".bash_profile" - Unix & Linux Stack Exchange
Browsing all 9 articles
Browse latest View live

Answer by Robin A. Meade for cron ignores variables defined in ".bashrc" and...

You could invoke bash with the -l option, like this: * * * * * /bin/bash -l /path/to/script arg1 arg2 The -l option makes bash a login shell. Thus, it will read the user's .bash_profile. It won't read...

View Article


Answer by Shyam Jos for cron ignores variables defined in ".bashrc" and...

I had the same issue when executing a node application from cron which uses NVM , In order to make bash shell to read the .bashrc file from cron just envoke the bash command with interactive shell...

View Article


Answer by Francois Marier for cron ignores variables defined in ".bashrc" and...

Something else that might interfere with the sourcing of your .bashrc from a cronjob is any checks that this file does in order to detect interactive shells. For example, on Ubuntu 18.04, the default...

View Article

Answer by Arcticooling for cron ignores variables defined in ".bashrc" and...

My way to deal with it was this: 1) Putting my variables in (the end of) ~/.profile: myVarInDotProfile="someValue" 2) Creating a Bash script for my (daily) cron tasks (~/cronDaily.sh) containing my...

View Article

Answer by Bach Lien for cron ignores variables defined in ".bashrc" and...

bash acts differently whether it is a shell or a normal programming language (like perl or python). By design, the settings in ~/.bash_profile, ~/.bashrc, etc. are for users to set things when bash...

View Article


Answer by Jonathan for cron ignores variables defined in ".bashrc" and...

You may not be able to run source if the sh shell is being used. This can be changed by adding the following line in your crontab: SHELL=/bin/bash * * * * * source "/root/.bashrc"; <command> You...

View Article

Answer by gNU.be for cron ignores variables defined in ".bashrc" and...

You can source the file you want at the top of the script or beginning of the job for the user that is executing the job. The "source" command is a built-in. You'd do the same thing if you made edits...

View Article

Answer by Dave C for cron ignores variables defined in ".bashrc" and...

Because it's not an interactive shell. The same happens when you open some terminals. Have a look at this question: What is the .bashrc file? | Super User And also at this one: What's the difference...

View Article


cron ignores variables defined in ".bashrc" and ".bash_profile"

I have defined "SHELL" variable in /etc/crontab file: [martin@martin ~]$ grep SHELL /etc/crontab SHELL=/usr/local/bin/bash [martin@martin ~]$ file /usr/local/bin/bash /usr/local/bin/bash: ELF 32-bit...

View Article

Browsing all 9 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>