以编程方式创建的文件在 Linux 后变为 NULL
Programatically created files become NULL in Linux
我有一个 shell 脚本,它通过将变量的内容写入内存位置的文件来以编程方式创建文件。
file=/downloads/fileName.crt
variable="These contents are to be
written to the file"
echo "$variable" > "$file"
这很好用。我能够看到该文件已写入而不是 NULL。但有时在 运行 这个脚本和重启后,文件内容变为 NULL。为什么会这样?
Link 至完整代码:
Newly created file becomes NULL on reboot in Linux
此代码是 运行 在具有非常基本配置的工业移动 Linux 计算机上。
尝试
sync
在脚本结尾。
我有一个 shell 脚本,它通过将变量的内容写入内存位置的文件来以编程方式创建文件。
file=/downloads/fileName.crt
variable="These contents are to be
written to the file"
echo "$variable" > "$file"
这很好用。我能够看到该文件已写入而不是 NULL。但有时在 运行 这个脚本和重启后,文件内容变为 NULL。为什么会这样?
Link 至完整代码:
Newly created file becomes NULL on reboot in Linux
此代码是 运行 在具有非常基本配置的工业移动 Linux 计算机上。
尝试
sync
在脚本结尾。