以编程方式创建的文件在Linux中变为NULL [英] Programatically created files become NULL in Linux

查看:95
本文介绍了以编程方式创建的文件在Linux中变为NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Shell脚本,可以通过将变量的内容写入内存位置中的文件来以编程方式创建文件.

I've a shell script which create files programmatically by writing the contents of a variable to a file in the memory location.

file=/downloads/fileName.crt
variable="These contents are to be
          written to the file"
echo "$variable" > "$file"

这很好.我可以看到文件已写入,而不是NULL.但是有时在运行此脚本后并重新引导后,文件内容变为NULL.为什么会这样?

This works fine. I'm able to see that the file is written to and not NULL. But sometimes after running this script and after a reboot, the file contents become NULL. Why is this happening?

链接到完整代码:

在Linux中重启后,新创建的文件变为NULL

此代码在具有非常基本配置的工业移动Linux计算机上运行.

This code is running on an industrial mobile Linux computer with very basic configuration.

推荐答案

尝试

sync

在脚本末尾.

这篇关于以编程方式创建的文件在Linux中变为NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆