LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-23-2014, 04:13 PM   #1
fidividi
LQ Newbie
 
Registered: Oct 2014
Posts: 2

Rep: Reputation: Disabled
Red face Reading Cronjob Output


I have a task setup to run on my cronjob where I need to read the output. What I need from the output is the starting character (let's say 'A') and the ending character (let's say 'Z'). A helps me understand my script started from the right place, and Z helps me understand my script finished at the right place.

So, it is important for me to run that cronjob, and see that my output is having proper A and Z.

I know that not sending the script to '> /dev/null' will try to mail using the MTA, which is not something I want to do. I also don't want to send it to /dev/null because I need to read the output.

When I run my script normally from the console (tty), I am able to see the start character (A) and end character (Z), but when I let the cronjob run, my script fails to read the start character and complains about 'no start characters'.

What can be the problem?

Thank you.
 
Old 10-23-2014, 05:03 PM   #2
rigor
Member
 
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705

Rep: Reputation: Disabled
Hi fidividi!

In an early part of your post, you seemingly wrote about using, for example, 'A' and 'Z' as output.

Later, you wrote about your script reading, for example, 'A' and 'Z'.

From that it seems unclear as to exactly what needs your script has. Even apart from that, it would probably help in general, to have more details.

I feel it can be helpful, when writing a script to run as a cron job, to use absolute file paths for all files. Any output you want to see that you don't want to be E-mailed to you, or appear in the system log files, you can write to specific disk files, rather than stdout or stderr.

HTH.
 
Old 10-23-2014, 11:10 PM   #3
vlrk
Member
 
Registered: Dec 2008
Posts: 51

Rep: Reputation: 1
Hi fidividi!


Few queries i did not get here.

1.Is your script kept in crontab?.
2.When you run your script from in terminal,are you redireting output to any diskfile / is it only on stdout?.
3.If your script is in crontab , where your output is expected is it in /var/log file system or in any file.

thanks
vlrk
 
Old 10-24-2014, 02:17 AM   #4
fidividi
LQ Newbie
 
Registered: Oct 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hello,

Thank you both for your replies. And apologies if my query isn't as clear, part of this is because the script is not written by me, I know what it is supposed to do and I need to fix it, and I believe I have enough information to know what is wrong, just need to know how to fix it.

@Rigor: When the script runs, the output is bunch of lines and strings, the starting character (in this example A) and the ending character (Z) are the part of output, from which my script needs to read to know if it ran successfully. Maybe what was confusing you is that how can the script read the output if it has finished running. The script calls sub-script, each open a process in CPU, run, and report back to the main script by their output. All outputs are prepared for the main script to know the result of sub-scripts.
Sending to log file is not an option for this script, it is just not written like that and I can not change it.


@Virk: Yes, it is stored in crontab. From terminal, only stdout, and I can see the A and the Z properly. And no, there is no output to any log files.


It is worth mentioning that this script works on Windows and Mac, this issue so far is only on Linux.

Thank you.
 
Old 10-24-2014, 11:10 AM   #5
rigor
Member
 
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705

Rep: Reputation: Disabled
fidividi,

If this is something to which you have legitimate access, and is not a homework assignment, then even if the script has to perform some specific action, you should be able to make changes for monitoring purposes. The output for monitoring purposes could be on a different file descriptor, so that it would not interfere with the purpose of the script.
 
Old 10-24-2014, 12:47 PM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
I still don't understand the problem. How many scripts are you talking about here? Which one(s) are you trying to put in the cron? Why can't you redirect the output to a log file or directly to your parsing program?

As far as I'm concerned, there are four kinds of programs
1) Ones that print output you care about to stdout/stderr
2) Ones that print output you don't care about to stdout/stderr
3) Ones that print output to a log file
4) Ones that don't have any output

#1 - just redirect the output to a log file of your choosing or pipe it to the input of some other program directly
#2 - just redirect the output to /dev/null
#3 - it's already taken care of for you
#4 - there is no output, so it doesn't matter
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Help Reading System Output jali1235 Linux - Newbie 2 08-30-2014 10:51 AM
PS command output reading ilnli Linux - General 3 10-15-2012 02:31 PM
lsof output not redirecting in a cronjob threezerous Linux - Newbie 3 09-27-2011 05:39 PM
Email Myself Output of Cronjob? carlosinfl Linux - Server 15 05-21-2010 11:47 AM
Reading output from netstat the_gripmaster Linux - Networking 1 10-24-2008 12:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:15 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