Search code examples
raspberry-pinode-redprivilegesreboot

shutdown cannot be executed by node-red exec node in raspberry pi


I am having the following issue:

  • I have node-red installed on a raspberry pi (Linux)
  • I am running a script where I do the following (myscript.sh - found in /home/pi):

    echo $USER

    echo $UID

I can run that script from bash and node-red with the same result:

pi
1000

But when I try the shutdown command:

shutdown -r now

I cannot execute that from node-red but I can execute it without problems from bash, although the same user is there (pi).

Is there an explanation for this?

Thanks!


Solution

  • Try with using

    sudo shutdown -r now 
    

    You are running node-red as a regular user, not as a superuser. Meanwhile, bash is always run as superuser.