Rule DSL behaving differently when called as an action from a cell in the UI

  • Platform information:
    • Hardware: Raspberry pi 4
    • OS: Openhabian
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: OH3.4

I am using OH 3.4 installed with openhabian on a raspeberry pi v4 4Gb,
together with some other external services such as HABApp, mosquitto, TheengsGateway, tuya.
Periodically (typically after few weeks but not systematically) the system stops working properly until I reboot: maybe there’s a memory leak somewhere. I am trying to figure out where the trouble is, meanwhile, as this is the production system, I am also implementing a way to make rebooting simpler.

The Problem
Instead of logging through ssh and manually issuing the commands, I have implemented a rule to reboot, following advice found in this and this thread.
The problem I have is that the rule do not run properly when called as an action from a cell in the overview page, while it works when I run it manually.
Are there any suggestions to make it run from the overview page? Should I try with some other rule language?

The details
The bash script is the following

sudo systemctl stop zram-config.service
sudo systemctl stop habapp.service
sudo /usr/sbin/reboot

the reason for stopping zram is to ensure that persistence is recorded on the SD card, as it happened (very very rarely, but it is still annoying) that it was lost after a reboot.
All permissions are set correctly as I verified by issuing the command

sudo -u openhab ./srv/openhab-conf/ 

I have implemented through UI a rule DSL, which calls the previous script

configuration: {}
triggers: []
conditions: []
  - inputs: {}
    id: "1"
      type: application/vnd.openhab.dsl.rule
      script: >-
        logInfo("Flag_System", "Rebooting openHAB")
        RebootOpenHAB_Message.sendCommand("Reboot sent")
    type: script.ScriptAction

If I test the rule by running it manually through the UI, the reboot is performed.

Finally, I created a simple cell on the overview page, in order to call the rule,
but the final result is that openhab is restarted, zram-config is stopped but the reboot does not occur

component: oh-cell
  action: rule
  actionRule: RebootOpenHAB
  header: ='UpTime:'+items.Raspi_3_OH34_System_Uptime.state
  on: "=items.RebootOpenHAB_Message.state == 'Click to reboot' ? false : true"
  subtitle: =items.RebootOpenHAB_Message.state
  title: Reboot Cell