Добрый день.
Есть компьютер, задача которого выполнять только некую программу на java.
Для запуска написал простой скрипт:
root@BGGate:~# cat /etc/init.d/bggate
#! /bin/sh
### BEGIN INIT INFO
# Provides: bggate
# Required-Start: sshd
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
echo `date`: 0:$0 1:$1 2:$2 3:$3 4:$4 RL:`runlevel` >> /root/runlog
case "$1" in
start)
sudo -H -u root nohup /opt/jdk/bin/java -jar /opt/bggate/BGGate.jar 1>/root/log 2>&1 &
;;
stop)
pkill java
;;
status)
ps -f -C java
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/bggate {start|stop|status|restart}"
exit 1
;;
esac
exit 0
Сделал, как и положено, update-rc.d bggate defaults.
Но скрипт запускается дважды (вывод из скрипта
echo `date`: 0:$0 1:$1 2:$2 3:$3 4:$4 RL:`runlevel` >> /root/runlog
):
root@BGGate:~# cat /root/runlog
Mon Sep 26 17:19:38 MSK 2016: 0:/etc/rc6.d/K20bggate 1:stop 2: 3: 4: RL:2 6
Mon Sep 26 17:20:14 MSK 2016: 0:/etc/rc2.d/S20bggate 1:start 2: 3: 4: RL:N 2
Mon Sep 26 17:22:15 MSK 2016: 0:/etc/rc2.d/S20bggate 1:start 2: 3: 4: RL:N 2
Просто спустя две минуты скрипт запускается еще раз.
Немного о системе:
root@BGGate:~# uname -a
Linux BGGate 3.4.39-01-lobo #1 SMP PREEMPT Sun Oct 25 14:51:50 CET 2015 armv7l armv7l armv7l GNU/Linux
root@BGGate:~# cat /proc/version
Linux version 3.4.39-01-lobo (boris@UbuntuMate) (gcc version 4.6.3 20120201 (prerelease) (crosstool-NG linaro-1.13.1-2012.02-20120222 - Linaro GCC 2012.02) ) #1 SMP PREEMPT Sun Oct 25 14:51:50 CET 2015
root@BGGate:~# ls -l /etc/rc2.d
total 4
-rw-r--r-- 1 root root 677 Feb 17 2016 README
lrwxrwxrwx 1 root root 17 Aug 31 13:51 S16openvpn -> ../init.d/openvpn
lrwxrwxrwx 1 root root 16 Sep 26 16:29 S20bggate -> ../init.d/bggate
lrwxrwxrwx 1 root root 15 Sep 8 16:31 S20osspd -> ../init.d/osspd
lrwxrwxrwx 1 root root 15 Aug 28 2015 S20rsync -> ../init.d/rsync
lrwxrwxrwx 1 root root 24 Sep 8 21:27 S20screen-cleanup -> ../init.d/screen-cleanup
lrwxrwxrwx 1 root root 13 Aug 28 2015 S23ntp -> ../init.d/ntp
lrwxrwxrwx 1 root root 16 Sep 8 19:56 S60motion -> ../init.d/motion
lrwxrwxrwx 1 root root 18 Aug 28 2015 S99ondemand -> ../init.d/ondemand
lrwxrwxrwx 1 root root 18 Aug 28 2015 S99rc.local -> ../init.d/rc.local
root@BGGate:~# cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# ** Overclock to 1.728 GHz
#echo 1728000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 0 > /proc/sys/kernel/hung_task_timeout_secs
#sudo -H -u root nohup /opt/jdk/bin/java -jar /opt/bggate/BGGate.jar 1>/root/log 2>&1 &
dmesg -n 1
exit 0
Подскажите, пожалуйста, куда покопать, что еще указать?