Using crontab to turn on and off 'mesg'

Using crontab to turn on and off 'mesg'

Post by Keith E. Flemin » Sun, 08 Feb 1998 04:00:00



Hello, I have been using Linux for a long time but this one has me
stumped. I want to turn off messages (mesg n) at 11pm and turn them back
on (mesg y) at 7am. The entries in my crontab look like this:

0 23 * * * /usr/bin/mesg n 2>&1 1>/dev/null
0 7 * * * /usr/bin/mesg y 2>&1 1>/dev/null

Apparently, the command does not get run, and I get a damned email every
time it unsuccessfully executes both lines. I have several other crontab
entries (taking pictures, deleting old files, etc.) and they all work
fine. I have read the FM, and I do not use RedHat 4.2

From the command line, if I type in:

/usr/bin/mesg y 1>/dev/null

It toggles the mesg from n to y. But if I then type in:

/usr/bin/mesg n 2>/dev/null

It has no effect. Does 'mesg' send something important to stderr? If so,
is there a way to get it to work AND to not get those damned emails from
cron?

Any help will be appreciated..
--
http://207.42.61.74       Online image!!!       ftp://207.42.61.74/pub
   ***   Need Linux users in Atlanta area to help establish   ***
   ***            a voice/data LOS laser network              ***

 
 
 

Using crontab to turn on and off 'mesg'

Post by Bill Curri » Wed, 11 Feb 1998 04:00:00



> Hello, I have been using Linux for a long time but this one has me
> stumped. I want to turn off messages (mesg n) at 11pm and turn them back
> on (mesg y) at 7am. The entries in my crontab look like this:

> 0 23 * * * /usr/bin/mesg n 2>&1 1>/dev/null
> 0 7 * * * /usr/bin/mesg y 2>&1 1>/dev/null

> Apparently, the command does not get run, and I get a damned email every
> time it unsuccessfully executes both lines. I have several other crontab
> entries (taking pictures, deleting old files, etc.) and they all work
> fine. I have read the FM, and I do not use RedHat 4.2

I don't know if this is what's causing your problem, but you are
redirecting stderr to whatever stdout was BEFORE redirection. ie your
lines should be:

0 23 * * * /usr/bin/mesg n 1>/dev/null 2>&1
0 7 * * * /usr/bin/mesg y 1>/dev/null 2>&1

HTH
Bill
--
Leave others their otherness