Jelastic - 如何修复 bash_profile 创建环境变量时输入的无效字符?

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

提前,我为我的英语道歉。 在研究如何解决问题时,我发现了 Jelastic 关于创建环境变量的建议。在没有这些知识的情况下,我创建了变量,就像我在 linux 中创建的那样,如果出现错误,我可以轻松地编辑 bash_profile 文件。这在 Jelastic 服务器上不会发生。 错误是我在 bash_profile 中声明环境变量时插入了不正确的行。这些行生成警告,如打印所示。我做了很多研究,但无法弄清楚如何解决它。你能帮帮我吗?

导致问题的行是: export BACKUP_DELETE_SCHEDULE=0 0 * * 1-5。 在终端输入命令 echo "export BACKUP_DELETE_SCHEDULE=0 0 * * 1-5" >> ~/.bash_profile

enter image description here

1。出了什么问题?

export BACKUP_DELETE_SCHEDULE=0 0 * * 1-5

被解释为:

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

要将所有这些放入变量中,您必须将其用引号引起来:

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

所以附加到现有的 ~/.bash_profile 文件将是这样的:

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

2。如何修复

在 Jelastic 节点上,此文件故意不可编辑(仅限 append-able):

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

含义:

  • 设置了 'a' 属性的文件只能以追加模式打开进行写入。
  • 'e' 属性表示该文件正在使用盘区映射磁盘上的块。

因此您需要:

  • 删除节点(并创建一个新节点)
  • 联系您的托管服务提供商的支持团队寻求帮助,从您的 .bash_profile
  • 中删除问题行

显然,首选选项取决于您是否需要此节点上的数据...

3。以后如何避免

除了不犯错误(见 #1),Jelastic documentation describes another way - 他们建议创建一个 ~/.bashrc 文件(如果有任何错误,您将拥有完全编辑权限)其中 Jelastic 已经在 ~/.bash_profile.

内自动 source

请注意何时使用 .bash_profile.bashrc 的区别:

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