Avoid bash command output to logged

37 views Asked by At

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?

1

There are 1 answers

0
lenny1972 On

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 &