如何在 rc.local 中启动 2 个 tmux 会话?

如何在 rc.local 中启动 2 个 tmux 会话?

这是我的/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.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

#added2rebootRunTmuxReconnectSchedule
echo > /tmp/test1.txt
sleep 10
tmux new -d -s mqttListen 'python /home/pi/Documents/python/mqttReceive.py' 
#\; set -t mqttListen remain-on-exit on;
tmux new -d -s tsrbrclocal 'python /home/pi/Documents/python/tsrb430v3.py' 
#sudo -u pi bash /home/pi/tmux_start.sh &

exit 0

但重启后只有第二个 ( tsrbrclocal) 可以正常启动。另一个显示管道损坏错误,连接后死机。我必须将其关闭,然后重启,它才能正常工作。

outside
Traceback (most recent call last):
  File "/home/pi/Documents/python/mqttReceive.py", line 49, in <module>
    client.connect(MQTT_SERVER, 1883, 60)
  File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 839, in connect
    return self.reconnect()
  File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 962, in reconnect
    sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
  File "/usr/lib/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 101] Network is unreachable



Pane is dead

其中“outside”一词是我的调试日志之一,其后是系统日志。

相关内容