cron output redirection

cron output redirection

Post by Bruc » Sun, 31 Dec 1899 09:00:00



I do not want to receive the output of a cron job in my mail so I've
redirected stderr and stdout to /dev/null. However, this doesn't seem to
be working because I'm still receiving the output in my mail.

To test this, I've set up a cron job as follows:

0,12,24,36,48 * * * * ping -c 3 apache.org

For this job, I receive the following output in my mail:

PING apache.org (63.211.145.10): 56 data bytes
64 bytes from 63.211.145.10: icmp_seq=0 ttl=240 time=157.0 ms
64 bytes from 63.211.145.10: icmp_seq=1 ttl=240 time=213.4 ms
64 bytes from 63.211.145.10: icmp_seq=2 ttl=240 time=198.7 ms

--- apache.org ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 157.0/189.7/213.4 ms

If I change the cron job to the following:

0,12,24,36,48 * * * * ping -c 3 apache.org 2>&1 > /dev/null

I still receive the same output in my mail.

Why is the output still being sent to my mailbox?

Thanks,
Bruce

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

cron output redirection

Post by Andy Smi » Fri, 24 Nov 2000 11:45:47


Is the MAILTO variable set in the crontab?

Andy



Quote:>I do not want to receive the output of a cron job in my mail so I've
>redirected stderr and stdout to /dev/null. However, this doesn't seem to
>be working because I'm still receiving the output in my mail.

>To test this, I've set up a cron job as follows:

>0,12,24,36,48 * * * * ping -c 3 apache.org

>For this job, I receive the following output in my mail:

>PING apache.org (63.211.145.10): 56 data bytes
>64 bytes from 63.211.145.10: icmp_seq=0 ttl=240 time=157.0 ms
>64 bytes from 63.211.145.10: icmp_seq=1 ttl=240 time=213.4 ms
>64 bytes from 63.211.145.10: icmp_seq=2 ttl=240 time=198.7 ms

>--- apache.org ping statistics ---
>3 packets transmitted, 3 packets received, 0% packet loss
>round-trip min/avg/max = 157.0/189.7/213.4 ms

>If I change the cron job to the following:

>0,12,24,36,48 * * * * ping -c 3 apache.org 2>&1 > /dev/null

>I still receive the same output in my mail.

>Why is the output still being sent to my mailbox?

>Thanks,
>Bruce

>Sent via Deja.com http://www.deja.com/
>Before you buy.


 
 
 

cron output redirection

Post by Wayne Polloc » Sun, 31 Dec 1899 09:00:00


The order of redirections is significant!  Try this:
 0,12,24,36,48 * * * * ping -c 3 apache.org >/dev/null 2>&1

-Wayne Pollock


> I do not want to receive the output of a cron job in my mail so I've
> redirected stderr and stdout to /dev/null. However, this doesn't seem to
> be working because I'm still receiving the output in my mail.
> ...
> If I change the cron job to the following:

> 0,12,24,36,48 * * * * ping -c 3 apache.org 2>&1 > /dev/null

> I still receive the same output in my mail.

> Why is the output still being sent to my mailbox?

 
 
 

cron output redirection

Post by Bruc » Sun, 31 Dec 1899 09:00:00


Now I've dumped the entire crontab so that there is nothing in it and
it's still running the old cron job that pings. What in the world is
going on? I've removed everything from the crontab, so shouldn't it stop
running the job?

Bruce

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

cron output redirection

Post by Wayne Polloc » Sun, 31 Dec 1899 09:00:00


Are you editing the crontab file directly?  Then you need to
restart cron daemon so it knows about the change.

It is better to use the "crontab -e" command to edit your crontab
file.

-Wayne Pollock


> Now I've dumped the entire crontab so that there is nothing in it and
> it's still running the old cron job that pings. What in the world is
> going on? I've removed everything from the crontab, so shouldn't it stop
> running the job?

> Bruce

> Sent via Deja.com http://www.deja.com/
> Before you buy.

 
 
 

1. Cron output redirection problem

Hi all,
Hope someone can lend me a hand with this problem.
Our site uses sysback to perform our backups and it's kicked off by cron
with the command
/usr/sbin/sysback -f vdev0 vg1 vg2 vg3 >/tmp/log 2>&1

When the job is kicked off it writes to the logfile, then runs an
fsback.pre script which appends stuff to the logfile. The script is used
to kill users, shutdown database etc prior to actually doing the backup.

My problem is that when sysback starts the backup it start writing to the
logfile where it left off not at the end of the file ie it overwrites the
messages the fsback.pre script put in.

I've tried various redirection operators to try and fix it but have come
across the right options as yet.  I expect it's got someting more to do
with file descriptors, subshells or the like but if anyone can lend
advice it would be appreciated.

Thanks
--------------
Nigel Longmire

2. USB Intellimouse Explorer setup

3. Cron and standard output redirection

4. need help in setting Slackware release of Linux on my PC

5. Repost of "Output redirection while reformatting the output"

6. NIC busy on laptop

7. Output redirection while reformatting the output

8. Fallback to modem script?

9. Modify Cron mail subject from displaying "Output from Cron"

10. cron - shell script would not generate output in cron

11. cron output in /var/cron/log

12. redirection didn't work in cron

13. cron.deny and cron.allow files for CRON management