Re: issue with launching screen process with monit

"[email protected]" <[email protected]> Wed, 22 Oct 2025 13:59:12 +0200
Newsgroups gmane.comp.monitoring.monit.general
Message-ID <[email protected]>
--Apple-Mail=_14727A0A-5556-4E6F-A9C9-C251BB15C37C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

Please can you provide more details?

You upgraded monit to 5.35.2, then rebooted the server 6 times and the =
problem persists? (~5 boots success, after ~6th error after first cycle =
despite the "if 5 restarts within 5 cycles then unmonitor" settings?)

What platform it exactly is? (linux or BSD version?)

Please can you add the process PID to the "screen process started =
successfully" log message?

Please can you send full monit log to [email protected]?

Best regards,
Martin



> On 22. 10. 2025, at 13:35, Kacper K=C5=82ys DMCS <[email protected]> =
wrote:
>=20
> Hi Martin,=20
>=20
> no changes for 5.35.0 and 5.35.2
>=20
> Kacper
>=20
>=20
>=20
> W dniu 22.10.2025 o 13:05, [email protected] =
<mailto:[email protected]> pisze:
>> Hi Kacper,
>>=20
>> it looks like a problem which was fixed in monit 5.35.0: The pidfile =
may contain a PID from the previous system boot, which belongs to a =
thread of different process after reboot.
>>=20
>> Please can you upgrade monit? (5.35.2 recommended)
>>=20
>> Best regards,
>> Martin
>>=20
>>=20
>>=20
>>> On 22. 10. 2025, at 10:54, [email protected] =
<mailto:[email protected]> wrote:
>>>=20
>>> Hi guys,=20
>>> I have a problem with the monit daemon on my ARM system. Once every =
5-6 times when I'm restarting the whole system, it happens that the =
screen process controlled by monit fails to start. I do not understand =
why. In monit logs or in system logs, there is no helpful information. =
Additionally, when monit claims that the process fails (and unmonitors =
it), I can see the proper screen process with a correct pid file =
available on the system. When I manually press "start service" in monit =
web gui, the correct process is found by monit. My monit version is =
5.34.3.
>>>=20
>>> I also do not understand how fast monit claims that the process =
fails to start and unmonitors it (in monit logs look like it takes 1-2 =
sec while timeout in monitrc for this process is 10 seconds).
>>>=20
>>> monitrc file:
>>> set daemon 20
>>> set onreboot start
>>> set log /var/log/monit.log
>>>=20
>>> check process screenprocess with pidfile /var/run/screenprocess.pid
>>>     if not exist then start
>>>     start program =3D "/etc/init.d/screenprocess start" with timeout =
10 seconds
>>>     stop program =3D "/etc/init.d/screenprocess stop" with timeout =
10 seconds
>>>     if 5 restarts within 5 cycles then unmonitor
>>>=20
>>> screenprocess init.d script:
>>>=20
>>> #!/bin/sh
>>>=20
>>> PIDFILE=3D/var/run/screenprocess.pid
>>> SCREEN_PATH=3D/tmp/screen
>>>=20
>>> case "$1" in
>>>   start)
>>>     logger -t screenprocess "Starting ioc"
>>>     echo "Starting ioc"
>>>     if [ -f "$PIDFILE" ]; then
>>>       logger -t screenprocess "Screen process is already running."
>>>       echo "Screen process is already running."
>>>       exit 1
>>>     fi
>>>     # create dir for screen socket files
>>>     mkdir -p $SCREEN_PATH
>>>     chmod 700 $SCREEN_PATH
>>>     export SCREENDIR=3D$SCREEN_PATH
>>>     # set stack limit
>>>     ulimit -s 1024
>>>     # run screen
>>>     screen -c /etc/screenprocesslogs.conf -dmSL screenprocess =
./start.cmd && sleep 1
>>>     # get pid of screen
>>>     screen -ls | grep -oE "[0-9]+\.screenprocess" | sed -e =
"s/\..*$//g" | tail -n 1 > $PIDFILE
>>>     if [ -f "$PIDFILE" ]; then
>>>       NUM_PIDS=3D$(grep -E '^[0-9]+$' "$PIDFILE" | wc -l)
>>>       # check if only one screen session is active
>>>       if [ $NUM_PIDS -eq 1 ]; then
>>>         logger -t screenprocess "Screen process started =
successfully."
>>>         echo "Screen process started successfully."
>>>       else
>>>         logger -t screenprocess "Failed to start Screen process. =
Multiple PIDs or none detected"
>>>         echo "Failed to start Screen process. Multiple PIDs or none =
detected"
>>>         exit 1
>>>       fi
>>>     else
>>>       logger -t screenprocess "Failed to start Screen process. PID =
file $PIDFILE not created"
>>>       echo "Failed to start Screen process. PID file $PIDFILE not =
created"
>>>       exit 1
>>>     fi
>>>     ;;
>>>=20
>>>=20
>>> Logs from monit:
>>> [2025-10-22T08:27:22+0000] debug    : pidfile =
'/var/run/screenprocess.pid' does not exist
>>> [2025-10-22T08:27:22+0000] error    : 'screenprocess' process is not =
running
>>> [2025-10-22T08:27:22+0000] debug    : =
--------------------------------------------------------------------------=
-----
>>> [2025-10-22T08:27:22+0000] debug    : =
--------------------------------------------------------------------------=
-----
>>> [2025-10-22T08:27:22+0000] debug    : pidfile =
'/var/run/screenprocess.pid' does not exist
>>> [2025-10-22T08:27:22+0000] info     : 'screenprocess' start: =
'/etc/init.d/screenprocess start'
>>> [2025-10-22T08:27:22+0000] info     : 'mgmt' start on user request
>>> [2025-10-22T08:27:22+0000] info     : 'screenprocess' start on user =
request
>>> [2025-10-22T08:27:22+0000] info     : Monit daemon with PID 251 =
awakened
>>> [2025-10-22T08:27:23+0000] debug    : Starting screen process
>>> screen process started successfully.
>>> [2025-10-22T08:27:24+0000] error    : 'screenprocess' service =
restarted 5 times within 5 cycles(s) - unmonitor
>>>=20
>>> I'd be grateful for any tips on what can be wrong.
>>>=20
>>> Cheers
>>>=20
>>> Kacper
>>>=20
>>>=20
>>>=20
>>=20


--Apple-Mail=_14727A0A-5556-4E6F-A9C9-C251BB15C37C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html aria-label=3D"message body"><head><meta http-equiv=3D"content-type" =
content=3D"text/html; charset=3Dutf-8"></head><body =
style=3D"overflow-wrap: break-word; -webkit-nbsp-mode: space; =
line-break: after-white-space;">Please can you provide more =
details?<div><br></div><div>You upgraded monit to 5.35.2, then rebooted =
the server 6 times and the problem persists? (~5 boots success, after =
~6th error after first cycle despite the "if 5 restarts within 5 cycles =
then unmonitor" settings?)</div><div><br></div><div>What platform it =
exactly is? (linux or BSD version?)</div><div><br></div><div>Please can =
you add the process PID to the "screen process started successfully" log =
message?</div><div><br></div><div>Please can you send full monit log to =
[email protected]?</div><div><br></div><div>Best =
regards,</div><div>Martin</div><div><br></div><div><br =
id=3D"lineBreakAtBeginningOfMessage"><div><br><blockquote =
type=3D"cite"><div>On 22. 10. 2025, at 13:35, Kacper K=C5=82ys DMCS =
&lt;[email protected]&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div>

 =20
    <meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3DUTF-8">
 =20
  <div><p>Hi Martin,&nbsp;</p><p>no changes for 5.35.0 and =
5.35.2</p><p>Kacper</p><p><br>
    </p>
    <div class=3D"moz-cite-prefix">W dniu 22.10.2025 o&nbsp;13:05,
      <a class=3D"moz-txt-link-abbreviated" =
href=3D"mailto:[email protected]">[email protected]</a> =
pisze:<br>
    </div>
    <blockquote type=3D"cite" =
cite=3D"mid:[email protected]">
      <meta http-equiv=3D"content-type" content=3D"text/html; =
charset=3DUTF-8">
      <div>Hi Kacper,</div>
      <div><br>
      </div>
      <div>it looks like a problem which was fixed in monit 5.35.0: The
        pidfile may contain a PID from the previous system boot, which
        belongs to a thread of different process after reboot.</div>
      <div><br>
      </div>
      <div>Please can you upgrade monit? (5.35.2 recommended)</div>
      <div><br>
      </div>
      <div>Best regards,</div>
      <div>Martin</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <br>
      <div>
        <blockquote type=3D"cite">
          <div>On 22. 10. 2025, at 10:54, <a =
class=3D"moz-txt-link-abbreviated" =
href=3D"mailto:[email protected]">[email protected]</a>
            wrote:</div>
          <div>
            <div style=3D"margin-top: 0px; margin-right: 0px; =
margin-bottom: 0px; margin-left: 0px;"><br>
            </div>
            <meta http-equiv=3D"content-type" content=3D"text/html; =
charset=3DUTF-8">
            <div><p>Hi guys,&nbsp;<br>
                I have a problem with the monit daemon on my ARM system.
                Once every 5-6 times when I'm restarting the whole
                system, it happens that the screen process controlled by
                monit fails to start. I do not understand why. In monit
                logs or in system logs, there is no helpful information.
                Additionally, when monit claims that the process fails
                (and unmonitors it), I can see the proper screen process
                with a correct pid file available on the system. When I
                manually press "start service" in monit web gui, the
                correct process is found by monit. My monit version is
                5.34.3.</p><p>I also do not understand how fast monit =
claims that the
                process fails to start and unmonitors it (in monit logs
                look like it takes 1-2 sec while timeout in monitrc for
                this process is 10 seconds).</p><p><b>monitrc =
file:</b><br>
                set daemon 20<br>
                set onreboot start<br>
                set log /var/log/monit.log<br>
                <br>
                check process screenprocess with pidfile
                /var/run/screenprocess.pid<br>
                &nbsp; &nbsp; if not exist then start<br>
                &nbsp; &nbsp; start program =3D =
"/etc/init.d/screenprocess start"
                with timeout 10 seconds<br>
                &nbsp; &nbsp; stop program =3D =
"/etc/init.d/screenprocess stop" with
                timeout 10 seconds<br>
                &nbsp; &nbsp; if 5 restarts within 5 cycles then =
unmonitor<br>
              </p><p><b>screenprocess init.d =
script:</b></p><p>#!/bin/sh<br>
                <br>
                PIDFILE=3D/var/run/screenprocess.pid<br>
                SCREEN_PATH=3D/tmp/screen<br>
                <br>
                case "$1" in<br>
                &nbsp; start)<br>
                &nbsp; &nbsp; logger -t screenprocess "Starting ioc"<br>
                &nbsp; &nbsp; echo "Starting ioc"<br>
                &nbsp; &nbsp; if [ -f "$PIDFILE" ]; then<br>
                &nbsp; &nbsp; &nbsp; logger -t screenprocess "Screen =
process is already
                running."<br>
                &nbsp; &nbsp; &nbsp; echo "Screen process is already =
running."<br>
                &nbsp; &nbsp; &nbsp; exit 1<br>
                &nbsp; &nbsp; fi<br>
                &nbsp; &nbsp; # create dir for screen socket files<br>
                &nbsp; &nbsp; mkdir -p $SCREEN_PATH<br>
                &nbsp; &nbsp; chmod 700 $SCREEN_PATH<br>
                &nbsp; &nbsp; export SCREENDIR=3D$SCREEN_PATH<br>
                &nbsp; &nbsp; # set stack limit<br>
                &nbsp; &nbsp; ulimit -s 1024<br>
                &nbsp; &nbsp; # run screen<br>
                &nbsp; &nbsp; screen -c /etc/screenprocesslogs.conf =
-dmSL
                screenprocess ./start.cmd &amp;&amp; sleep 1<br>
                &nbsp; &nbsp; # get pid of screen<br>
                &nbsp; &nbsp; screen -ls | grep -oE =
"[0-9]+\.screenprocess" | sed
                -e "s/\..*$//g" | tail -n 1 &gt; $PIDFILE<br>
                &nbsp; &nbsp; if [ -f "$PIDFILE" ]; then<br>
                &nbsp; &nbsp; &nbsp; NUM_PIDS=3D$(grep -E '^[0-9]+$' =
"$PIDFILE" | wc -l)<br>
                &nbsp; &nbsp; &nbsp; # check if only one screen session =
is active<br>
                &nbsp; &nbsp; &nbsp; if [ $NUM_PIDS -eq 1 ]; then<br>
                &nbsp; &nbsp; &nbsp; &nbsp; logger -t screenprocess =
"Screen process started
                successfully."<br>
                &nbsp; &nbsp; &nbsp; &nbsp; echo "Screen process started =
successfully."<br>
                &nbsp; &nbsp; &nbsp; else<br>
                &nbsp; &nbsp; &nbsp; &nbsp; logger -t screenprocess =
"Failed to start Screen
                process. Multiple PIDs or none detected"<br>
                &nbsp; &nbsp; &nbsp; &nbsp; echo "Failed to start Screen =
process. Multiple
                PIDs or none detected"<br>
                &nbsp; &nbsp; &nbsp; &nbsp; exit 1<br>
                &nbsp; &nbsp; &nbsp; fi<br>
                &nbsp; &nbsp; else<br>
                &nbsp; &nbsp; &nbsp; logger -t screenprocess "Failed to =
start Screen
                process. PID file $PIDFILE not created"<br>
                &nbsp; &nbsp; &nbsp; echo "Failed to start Screen =
process. PID file
                $PIDFILE not created"<br>
                &nbsp; &nbsp; &nbsp; exit 1<br>
                &nbsp; &nbsp; fi<br>
                &nbsp; &nbsp; ;;<br>
                <br>
              </p><p><b>Logs from monit:</b><br>
                [2025-10-22T08:27:22+0000] debug&nbsp; &nbsp; : pidfile
                '/var/run/screenprocess.pid' does not exist<br>
                [2025-10-22T08:27:22+0000] error&nbsp; &nbsp; : =
'screenprocess'
                process is not running<br>
                [2025-10-22T08:27:22+0000] debug&nbsp; &nbsp; :
=
--------------------------------------------------------------------------=
-----<br>
                [2025-10-22T08:27:22+0000] debug&nbsp; &nbsp; :
=
--------------------------------------------------------------------------=
-----<br>
                [2025-10-22T08:27:22+0000] debug&nbsp; &nbsp; : pidfile
                '/var/run/screenprocess.pid' does not exist<br>
                [2025-10-22T08:27:22+0000] info&nbsp; &nbsp; &nbsp;: =
'screenprocess'
                start: '/etc/init.d/screenprocess start'<br>
                [2025-10-22T08:27:22+0000] info&nbsp; &nbsp; &nbsp;: =
'mgmt' start on
                user request<br>
                [2025-10-22T08:27:22+0000] info&nbsp; &nbsp; &nbsp;: =
'screenprocess'
                start on user request<br>
                [2025-10-22T08:27:22+0000] info&nbsp; &nbsp; &nbsp;: =
Monit daemon with
                PID 251 awakened<br>
                [2025-10-22T08:27:23+0000] debug&nbsp; &nbsp; : Starting =
screen
                process<br>
                screen process started successfully.<br>
                [2025-10-22T08:27:24+0000] error&nbsp; &nbsp; : =
'screenprocess'
                service restarted 5 times within 5 cycles(s) - =
unmonitor<br>
              </p><p>I'd be grateful for any tips on what can be =
wrong.</p><p>Cheers</p><p>Kacper</p>
            </div>
            <br>
            <br>
          </div>
        </blockquote>
      </div>
      <br>
    </blockquote>
  </div>

</div></blockquote></div><br></div></body></html>=

--Apple-Mail=_14727A0A-5556-4E6F-A9C9-C251BB15C37C--