各位大侠:最近写了一个shell脚本,并赋予可执行权限,shell脚本配置为开机自动运行,shell里用touch创建一个文件,且用echo向这个文件写入一句话,结果发现touch、echo失效,没有实现预想的功能。但开启一个shell界面,在shell里用sh test.sh是可以的(其中test.sh是我shell脚本文件名)。test.sh脚本如下:
# !/bin/sh
currDateTime=`date +%Y%m%d%H%M%S`
prefilename="restartacqdatasys"
extendname=".log"
logfilename=${prefilename}$currDateTime$extendname
touch $logfilename
echo "AcqDataSys exit, restart the program!" > $logfilename
其中
touch $logfilename、
echo "AcqDataSys exit, restart the program!" > $logfilename
在开机自动运行时失效,但开启一个shell界面,在shell里用sh test.sh没问题可以实现预想功能。用vi编辑/etc/init.d/rcS加入我的shell脚本的绝对路径如下,以实现开机自动运行:

其中倒数第二行就是我的脚本,脚本绝对路径绝对没错的,开机时程序也启动起来了,但未见touch和echo功能实现。恳求大侠们支招