Apparently, the Node-RED restart works with this command, but with "node-red" instead of "nodered"!
#!/bin/bash #Yes, there was a space in my last post, but it wasn't in my script!
systemctl restart httpd
systemctl restart node-red
PID=$!
sleep 2
kill $PID
disown -h
I have another problem by the way: in this script, I want to kill de $PID because I have to press CTRL+C after the Node-RED restart. The GNU/Linux console replies:
kill : man kill page
line 8 : disown : current : unknown task (not sure about the translation from French)
I had to look up the meaning of $! - it's the PID of the last background process created.
As far as I can see, your script doesn't create any background processes, though your original version with node-red& did.
This might explain the problem with disown -h too.
So I suggest you get rid of
PID=$!
sleep 2
kill $PID
disown -h
If after doing that you still "have to press CTRL+C after the Node-RED restart", there is something wrong with your systemd script.
Your installation is not standard. Did the "official" installation instructions for CentOS https://github.com/node-red/linux-installers not work for you?
Did you follow some online tutorial? Why and which one?