shell脚本中使用nohup执行命令不生效

1 例如

!#/bin/bash
nohup echo "hello world"

  

2 解决办法

加上 source /etc/profile 就好了

!#/bin/bash
source /etc/profile
nohup echo "hello world"

  

3 原因

  找不到环境变量,所以先source一下

原文地址:https://www.cnblogs.com/QuestionsZhang/p/11178825.html