我有一个脚本,当系统第一次启动时运行。但同样的脚本第二次也只跳过了一个命令。
所以我试着使用变量,但似乎没有办法跟踪它。
例如:/var/tmp/runme.sh <<这个脚本将使用
#!/bin/bash
mkfifo pipe;
mkfifo pipe1;
ps aux | grep Java.jar | awk '{print $2}' | xargs kill -9;
sleep 1;
#
# Question on this:
# only one time it execute / its my application boot process
# - this is only one time on system startup
#
##############################################################
export DISPLAY=:0.0 && java -cp Java.jar main.Boot &
#
# second time this following should always execute
# This is my software kernel, which crash often
# on the fly i restart it
#
while true; do cat /var/jpeg1.jpeg >> pipe; done
while true; do cat /var/jpeg2.jpeg >> pipe1; done
export DISPLAY=:0.0 && java -cp Java.jar main.Desktop &发布于 2012-05-27 19:02:53
在/var/run中创建一个锁文件(假设您的系统在引导时自动清除/var/run -或者使用/tmp,如果这样做效果更好)。检查锁定文件是否存在,并根据是否存在采取不同的操作。
https://stackoverflow.com/questions/10773377
复制相似问题