Wall execution problems from cron

So I've been tasked with creating a shell script to run in a cron every few minutes to check duplex settings on my eth0 nic card. I would like for the server to send a wall message to whoever is on the console or in a terminal session. Below is what I have so far.

0,10,20,30,40,50 * * * *  /home/acc4000d/test10

I have it in my root's cron so that wall will run. Can someone tell me what I'm missing for the wall to actually happen?

Script looks like this;

#!/bin/bash
DUPLEX=$(ethtool eth0 | sed -n 's/Duplex:\(.*\)/\1/p')
if [ $DUPLEX = Half ]
then /usr/bin/wall duplex_error 
fi

annnnd the wall message file is called "duplex_error"

I don't see anything wrong. What is the script doing or not doing?

I don't think wall takes a file -- it'd just print 'duplex_error' instead of printing the message from that file.

xargs wall < duplex_error
1 Like

Strange. I would have bet it did. - This is from my current system's man page:

WALL(1)                   BSD General Commands Manual                  WALL(1)

NAME
     wall -- write a message to users

SYNOPSIS
     wall [-g group] [file]

DESCRIPTION
     The wall utility displays the contents of file or, by default, its standard input, on the terminals of all currently logged in users.

And here I was thinking "wall" was some kind of standard command.

I'm not seeing wall output my message. However, if i just run the script, it outputs the wall message to console as expected. So for some reason i can't get it to run properly from the cron itself.

---------- Post updated at 03:38 PM ---------- Previous update was at 03:35 PM ----------

I even added a log file to write to and i get no output to it either.

#!/bin/bash
DUPLEX=$(ethtool eth0 | sed -n 's/Duplex:\(.*\)/\1/p')
if [ $DUPLEX = Half ]
then /usr/bin/wall /home/acc4000d/duplex_error 
echo > /home/acc4000d/boogers_`date +\%b\%d\%y\%H\%M`.log 2>&1
fi

It may not be finding the location of ethtool and/or sed. Try using full paths just as you did with wall .

DUPLEX=$(/usr/bin/ethtool eth0 | /usr/bin/sed -n 's/Duplex:\(.*\)/\1/p')
1 Like

That did the trick, my friend, thank you!

Ah. I have a wall too, but it is opposite -- it takes a message, not a file. I'm not sure whose is more correct.