Skip to content
Advertisement

Jelastic – How to fix bash_profile with invalid characters entered when creating environment variables?

In advance, I apologize for my English. It was while researching how to solve the problem that I discovered Jelastic’s recommendations for creating environment variables. Without this knowledge, I created variables like I create in linux, where in case of error, I can edit the bash_profile file easily. Which doesn’t happen on Jelastic servers. The error is that I inserted incorrect lines when declaring environment variables in the bash_profile. These lines generated warnings as shown in the print. I did a lot of research and couldn’t figure out how to fix it. can you help me?

The line that caused the problem was: export BACKUP_DELETE_SCHEDULE=0 0 * * 1-5. Entered with command in terminal echo "export BACKUP_DELETE_SCHEDULE=0 0 * * 1-5" >> ~/.bash_profile

enter image description here

Advertisement

Answer

1. What went wrong?

export BACKUP_DELETE_SCHEDULE=0 0 * * 1-5

Is interpreted as something like:

export BACKUP_DELETE_SCHEDULE=0
export 0
export *
export *
export 1-5

To put all of that into the variable you must wrap it in quotation marks:

export BACKUP_DELETE_SCHEDULE="0 0 * * 1-5"

So appending to the existing ~/.bash_profile file would be like this:

echo 'export BACKUP_DELETE_SCHEDULE="0 0 * * 1-5"' >> ~/.bash_profile

2. How to fix it

On Jelastic nodes, this file is deliberately not editable (only append-able):

$ lsattr .bash_profile
-----a-------e-- .bash_profile

Meaning:

  • A file with the ‘a’ attribute set can only be opened in append mode for writing.
  • The ‘e’ attribute indicates that the file is using extents for mapping the blocks on disk.

Therefore you need to either:

  • delete the node (and create a new one)
  • contact your hosting provider’s support team for assistance to delete the problem line(s) from your .bash_profile

Obviously the preferred option depends if you need the data on this node or not…

3. How to avoid it in future

Besides not making the mistake (see #1), the Jelastic documentation describes another way – they suggest to create a ~/.bashrc file (which you would have full permissions to edit, in case of any mistakes) which Jelastic already automatically source within ~/.bash_profile.

Please also note the differences regarding when .bash_profile is used vs. .bashrc:

  • ~/.bash_profile is executed only upon login via console
  • ~/.bashrc is executed for each new bash instance
Advertisement