Automatic restart Node Red on Linux


How can i do an Automatic restart for Node Red on Linux at a certain time of day.
I have an application that reads on modbus using node-red-contrib-modbus and sometimes forgets to read the data, and i hope that this might solve my problem.

Thank you.


It might be more productive to find out why it stops and fix that.
How are you triggering the read? Have you put a debug node on that to make sure it is still working?
Display the node-red log in a terminal (node-red-log will do that if you have used the Pi install script) and see if anything unnexpected is shown when you start node-red and when the modbus stops.


I am using the modbus read node (Modbus TCP/Serial read node.), and reading the Holding registers. I've tried to search for the problem in the data base but it resolves when i make an FULL DEPLOY, the read node starts to read the data. This is the Flow:
[{"id":"efe3dba9.c09438","type":"modbus-read","z":"a87b22c2.6a19c","name":"","topic":"","showStatusActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"19000","quantity":"20","rate":"1","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"f904cf0e.d70d4","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":1018.0833892822266,"y":157.16320037841797,"wires":[["e07c9eb5.db0d6"],[]]},{"id":"e07c9eb5.db0d6","type":"function","z":"a87b22c2.6a19c","name":"write_to_DB_ALARME_FUNCTIONARE","func":"var msg1 = {};\nif (msg.payload[0] === false){\n msg1.payload = 0;\n msg1.topic = "INSERT INTO db_kmr.sensors_values (reg_date, id_sensor,value) VALUES (NOW(),'326','"+msg1.payload+"')";\n return msg1;\n \n}\nif (msg.payload[0] === true){\n msg1.payload = 1;\n msg1.topic = "INSERT INTO db_kmr.sensors_values (reg_date, id_sensor,value) VALUES (NOW(),'326','"+msg1.payload+"')";\n return msg1;\n}","outputs":1,"noerr":0,"x":1320.017333984375,"y":155.0104217529297,"wires":[["fea65863.a97458"]]},{"id":"fea65863.a97458","type":"function","z":"a87b22c2.6a19c","name":"changes-only6","func":"var alarm = {};\nvar al = -1;\nvar nochange = {};\nif (global.get("alarm6") === undefined){\n alarm.payload = al;\n alarm.topic = '';\n global.set("alarm6",alarm);\n}\nif (msg.payload !== global.get("alarm6").payload){\n alarm.payload = msg.payload;\n alarm.topic = msg.topic;\n global.set("alarm6",alarm);\n return alarm;\n}\nif (msg.payload === global.get("alarm6").payload){\n nochange.payload = "no change, last value: " + msg.payload;\n return nochange;\n}","outputs":1,"noerr":0,"x":1596.017333984375,"y":155.0104217529297,"wires":[["ef20abe4.05a418"]]},{"id":"ef20abe4.05a418","type":"mysql","z":"a87b22c2.6a19c","mydb":"5396c75e.697288","name":"","x":1815.795166015625,"y":159.0104217529297,"wires":[[]]},{"id":"f904cf0e.d70d4","type":"modbus-client","z":"","name":"Janitza UMG604E","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"19200","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"100","clientTimeout":"1000","reconnectTimeout":"2000"},{"id":"5396c75e.697288","type":"MySQLdatabase","z":"","host":"","port":"3306","db":"db_kmr","tz":""}]


I also have debug nodes everywhere


Unfortunately your flow is not importable. Please read the link below then edit your previous post to include the backtick characters as described there. You can check it is importable yourself after you have edited the post.


Sorry, new users can not upload attachments. I get this message. With the node Modbus Flex and an inject node seems we have solved the problem so far. Tx. Keep in touch


but you can edit your flow following the instructions...