shell script started with systemd filling journal

This forum is for discussion about general software issues.

shell script started with systemd filling journal

Postby lharmon » Mon Dec 22, 2014 7:27 pm

I am using a simple shell script, started by system, to set LEDs on a Marvell Armada 370 plug.
The script uses a while loop with a "sleep 30" line
Exiting sleep seems to log to the journal, filling it with useless info.
How can I change this behavior?

The journal output looks like:
Dec 22 19:19:12 rrap-0281aa.local LEDupdater.sh[188]: Active: active (running) since Mon 2014-12-22 18:30:45 UTC; 48min ago
Dec 22 19:18:57 rrap-0281aa.local LEDupdater.sh[188]: Active: active (running) since Mon 2014-12-22 18:30:45 UTC; 48min ago
Dec 22 19:18:42 rrap-0281aa.local LEDupdater.sh[188]: Active: active (running) since Mon 2014-12-22 18:30:45 UTC; 47min ago
Dec 22 19:18:27 rrap-0281aa.local LEDupdater.sh[188]: Active: active (running) since Mon 2014-12-22 18:30:45 UTC; 47min ago
Dec 22 19:18:12 rrap-0281aa.local LEDupdater.sh[188]: Active: active (running) since Mon 2014-12-22 18:30:45 UTC; 47min ago
Dec 22 19:17:57 rrap-0281aa.local LEDupdater.sh[188]: Active: active (running) since Mon 2014-12-22 18:30:45 UTC; 47min ago
Dec 22 19:17:42 rrap-0281aa.local LEDupdater.sh[188]: Active: active (running) since Mon 2014-12-22 18:30:45 UTC; 46min ago
Dec 22 19:17:27 rrap-0281aa.local LEDupdater.sh[188]: Active: active (running) since Mon 2014-12-22 18:30:45 UTC; 46min ago
lines 1-39




The service looks like this:

[root@rrap-0281aa system]# cat rrap_leds.service
[Unit]
Description=start LED service
After=syslog.target network.target

[Service]
Type=simple

ExecStart=/sbin/LEDupdater.sh

[Install]
WantedBy=multi-user.target
[root@rrap-0281aa system]#



My shell script while loop looks like this:
while true ; do

# blue is wifi status
if isHostapdUp ; then
echo "default-on" > $Trigger_Blue
else
echo "none" > $Trigger_Blue
if ! isInterfacePresent wlp1s0 ; then
FAILCNT=$((FAILCNT+1))
# echo "wlp1s0 is down $FAILCNT "
fi
fi

# yellow is eth1 status
if isInterfaceDown eth1 ; then
echo "none" > $Trigger_Yellow
else
echo "default-on" > $Trigger_Yellow
fi

if [ "$FAILCNT" -gt "$MAXFAILCNT" ] ; then
echo "missing wlp1s0; rebooting " `date` >> /var/log/pciBug.log
`reboot`
fi

sleep 15

done
lharmon
 
Posts: 46
Joined: Fri Apr 19, 2013 7:30 pm

Re: shell script started with systemd filling journal

Postby lharmon » Tue Dec 23, 2014 2:20 pm

I have come to the understanding that sleep is not a built in bash command and therefore spawns a task, which gets logged to the journal.

I have identified two possible solutions:
1) build the bash sleep loadable and use it
2) re-write my script in C or another language which does not spawn tasks
lharmon
 
Posts: 46
Joined: Fri Apr 19, 2013 7:30 pm

Re: shell script started with systemd filling journal

Postby lharmon » Tue Dec 23, 2014 8:11 pm

I have attempted to use the bash "loadable" sleep function. It worked as advertised, however it didn't prevent the unwanted journal logging. I guess the journal logs every time a service goes from a not-runnable state to a runnable state.
So now I am not even sure a C program would solve my issue, but I will try.

Any other suggestions?
lharmon
 
Posts: 46
Joined: Fri Apr 19, 2013 7:30 pm

Re: shell script started with systemd filling journal

Postby Socaltom » Tue Dec 23, 2014 9:31 pm

used to be owned by me
Pink Pogo V2, Black Pogo V3, Zyxel NAS 325 v1,
used to be Adminstrator for
Goflex net, Black V3, Black V2
Now I have a couple of raspberry pi ( 3+ and 4)
Socaltom
 
Posts: 571
Joined: Thu Apr 07, 2011 2:21 pm
Location: The left side

Re: shell script started with systemd filling journal

Postby lharmon » Mon Dec 29, 2014 7:40 pm

My shell script output isn't being put in the journal, it seems that systemd is simply reporting that my service is runnable, again and again and again....
lharmon
 
Posts: 46
Joined: Fri Apr 19, 2013 7:30 pm

Re: shell script started with systemd filling journal

Postby lharmon » Mon Dec 29, 2014 8:51 pm

SOLVED:

added "StandardOutput=null" to [Service] section of system service file
lharmon
 
Posts: 46
Joined: Fri Apr 19, 2013 7:30 pm


Return to General

Who is online

Users browsing this forum: No registered users and 10 guests