LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-23-2005, 11:33 AM   #1
Temujin_12
Member
 
Registered: Sep 2003
Location: Washington
Distribution: Kubuntu Dapper
Posts: 99

Rep: Reputation: 15
Cron output to a file


How do you tell cron to send the output to a file rather than send an email?
 
Old 02-23-2005, 11:55 AM   #2
Temujin_12
Member
 
Registered: Sep 2003
Location: Washington
Distribution: Kubuntu Dapper
Posts: 99

Original Poster
Rep: Reputation: 15
After more research it looks like there is not a way to tell cron to output to a file. Of course you can just modify your commands so that they pipe thier output to a file but my problem is that one of my cron jobs restarts apache and it runs a configtest which outputs "Syntax OK" to the screen regardless of wheither you piped it to a file or not.

Perhaps my question is how can I avoid the "Syntax OK" from being outputted?

I believe this is being outputted by Perl's "configtest" command. I do want the output from "configtest" to output when there is an error. I just don't want the "Syntax OK" message.

Last edited by Temujin_12; 02-23-2005 at 12:23 PM.
 
Old 02-23-2005, 12:45 PM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
The message "Syntax OK" seems to be just standard output and not an err message. So, you could redirect standard ouput to a file. Might as well redirect any errors as well. I would put that in the script at the end of your configtest line.

Here's a couple of examples:
ls nofile > test 2>&1 ## this one only has errors
ls /home > test 2>&1 ## this one only shows the result of ls because it has no errors.
 
Old 02-23-2005, 01:23 PM   #4
ivanatora
Member
 
Registered: Sep 2003
Location: Bulgaria
Distribution: Ubuntu 9.10, FreeBSD 7.2
Posts: 459

Rep: Reputation: 32
If you don't want it at all, send it to > /dev/null
 
Old 02-23-2005, 01:27 PM   #5
Temujin_12
Member
 
Registered: Sep 2003
Location: Washington
Distribution: Kubuntu Dapper
Posts: 99

Original Poster
Rep: Reputation: 15
I tried "ls nofile > test 2>&1" on my local Gentoo machine and it works just fine. But when I try "ls nofile > test 2>&1" on the FreeBSD system, where the cronjob is, it gives me "Ambiguous output redirect." Is the syntax different for "ls nofile > test 2>&1" on a FreeBSD system?

"ls nofile > test 2" works on the FreeBSD system but "Syntax OK" is still outputted to the screen while everything else from the script is piped to the file.

Last edited by Temujin_12; 02-23-2005 at 01:29 PM.
 
Old 02-23-2005, 01:52 PM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Those were only examples, not to put exactly like that in your script.

Here is an example which may be more meaningful to you....

configtest 1> /dev/null
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
cron output nelamvr6 Linux - Newbie 3 10-18-2005 07:11 PM
Can the output of cron daemon be sent via other smtp hamish Linux - Software 0 09-02-2005 08:28 AM
cron output? sk8guitar Linux - General 4 08-15-2003 01:55 PM
Understanding CRON output lhoff Linux - General 1 05-19-2003 01:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration