I have a script that needs to create temporary files for its work, and clean up after itself. My question is about finding the right base directory for the temporary files.
The script needs to work on multiple platforms: Git Bash (Windows), Solaris, Linux, OSX. On each platform, the preferred temp directory is expressed differently:
%TMP%
(and possibly %TEMP%
)$TMPDIR
$TMPDIR
but appears to be unset on multiple systems I triedSo …
我正在尝试转向/tmp
RAM 并遵守良好做法:
/var/tmp
不应放置在 中tmpfs
,因为它必须在重新启动后存活
不是/tmp
作为独立安装tmpfs
,而是依赖/dev/shm
或/run/shm
然而,事情在 2.6 和 3.2 内核之间发生了变化:
在 3.2 内核上,RAMTMP=yes
在/etc/default/tmpfs
.
我的问题是:如何使用旧内核实现这一目标?
我的选择不是修改 /etc/fstab 也不是:
mkdir /dev/shm/tmp
chmod 1777 /dev/shm/tmp
mount --bind /dev/shm/tmp /tmp
Run Code Online (Sandbox Code Playgroud)
RAMTMP
2.6 内核有类似的东西吗?