0

The command:

pi@raspberrypi:~ $ mosquitto
1566609792: mosquitto version 1.5.7 starting
1566609792: Using default config.
1566609792: Opening ipv4 listen socket on port 1883.
1566609792: Error: Address already in use

can be invoked to start mosquitto. Is there a better single command that can verify the broker is running. I would like to avoid using using pub and sub commands to test and use a simple query command. I would also like to avoid using the mosquitto command to determine if the installation is active / running

gatorback
  • 1,351
  • 4
  • 19
  • 44

1 Answers1

1

Assuming that you installed mosquitto using apt-get then it will have been set up as a systemd service so:

service mosquitto status

will show if it's running or not:

● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
   Active: active (running) since Mon 2019-08-12 22:39:38 BST; 1 weeks 4 days ag
     Docs: man:systemd-sysv-generator(8)
  Process: 32183 ExecStop=/etc/init.d/mosquitto stop (code=exited, status=0/SUCC
  Process: 32220 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SU
      CPU: 8min 53.255s
   CGroup: /system.slice/mosquitto.service
           └─32226 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

else just using ps will show if the process is running:

$ ps -efc | grep mosquitto
mosquit+ 32226     1 TS   19 Aug12 ?        00:08:53 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
hardillb
  • 54,545
  • 11
  • 67
  • 105