0

I'm searching for a way to avoid that some bash command executed from within a Node-Red process (running on my Raspberry Pi 3B+ device) will go into the /var/log/system log file of the Raspeberry OS (Stretch).

In particular I've got a node (within node-red) that each 30 seconds execute a bash command in order to kill any eventual process running on a serial device (connected to the Raspberry through a FTDI USB converter).

The command that I execute from within node-red is the following:

sudo fuser /dev/ttyFTDI_GAS -k

Most of the time there is no running process on the FTDI serial connected device so the command results in an error. In this case this error fill my system log file making it really "crowded" and difficult to read.

Below how my system file looks like.

May 27 07:30:59 raspberrypi Node-RED[349]: 27 May 07:30:59 - [info] [exec:96ba9b5a.d097b8] error:Error: Command failed: sudo fuser /dev/ttyFTDI_GAS -k

May 27 07:30:59 raspberrypi Node-RED[349]: 27 May 07:31:29 - [info] [exec:96ba9b5a.d097b8] error:Error: Command failed: sudo fuser /dev/ttyFTDI_GAS -k

May 27 07:30:59 raspberrypi Node-RED[349]: 27 May 07:31:59 - [info] [exec:96ba9b5a.d097b8] error:Error: Command failed: sudo fuser /dev/ttyFTDI_GAS -k

May 27 07:30:59 raspberrypi Node-RED[349]: 27 May 07:32:29 - [info] [exec:96ba9b5a.d097b8] error:Error: Command failed: sudo fuser /dev/ttyFTDI_GAS -k

When instead there is one or mode processes using the connected device this command (that's the reason for having used the "-k" option) will kill them and "free" the connected device so preparing it to be ready to accept a new serial communication with the Raspberry.

Is there a way to avoid showing in the system log all the outcome of the sudo fuser /dev/ttyFTDI_GAS -k command?

Community
  • 1
  • 1
  • Did you try `sudo fuser /dev/ttyFTDI_GAS -k 2>/dev/null` ? – Walter A Jun 01 '20 at 20:28
  • hi Walter thanks for driving me to the right path. Your suggestion didn't work for me. The way to suppress entry in the system log is the following `sudo fuser /dev/ttyFTDI_GAS -k > /dev/null 2>&1 &` – lenny1972 Jun 02 '20 at 15:41
  • You can post your solution as an answer and accept it or delete the question. I would be taking to much credit when I posted your solution an an answer. – Walter A Jun 02 '20 at 18:34

1 Answers1

0

The solution I've found in order to suppress each and every entry of the command in the system log is to add > /dev/null 2>&1 & at the end of the command, so in my example sudo fuser /dev/ttyFTDI_GAS -k > /dev/null 2>&1 &