Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Location of output from cron job

Posted on 2014-12-11
7
Medium Priority
?
111 Views
Last Modified: 2014-12-12
I 'm to run a script in cron but i'm not finding the output.  When i run manually, the output is right in the directory from which i execute.

select value || '_' output
from v$parameter where name = 'db_name';
spool lfsdiag_&&dbname&&timestamp&&suffix

what directory will this  lfsdiag_&&dbname&&timestamp&&suffix go when i run from cron?
0
Comment
Question by:xoxomos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 

Author Comment

by:xoxomos
ID: 40495491
Running RH5.7
0
 

Author Comment

by:xoxomos
ID: 40495494
crontab entry is :
55 20 * * 5 /home/oracle/scripts/lfsdiag.sh
~
0
 
LVL 18

Expert Comment

by:TobiasHolm
ID: 40495513
Put the path before the filename.

Try:

from v$parameter where name = 'db_name';
spool "/var/log/myfolder/"&&lfsdiag_&&dbname&&timestamp&&suffix

Create a folder and set rights so that the script can write to it.
mkdir /var/log/myfolder
chmod 777 /var/log/myfolder

Use appropriate users, groups and chmod on the folder. Above is just an example.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:xoxomos
ID: 40495529
--spool lfsdiag_&&dbname&&timestamp&&suffix
spool "/home/oracle/tosupport"&&lfsdiag_&&dbname&&timestamp&&suffix

-bash-3.2$ pwd
/home/oracle
-bash-3.2$ ls -la tosupport
total 8
drwxrwxrwx  2 oracle oinstall 4096 Dec 11 21:51 .
drwxr-xr-x 16 oracle oinstall 4096 Dec 11 22:16 ..


Not getting anything in tosupport directory
0
 
LVL 18

Accepted Solution

by:
TobiasHolm earned 2000 total points
ID: 40495632
Try to redirect output using > :

spool lfsdiag_&&dbname&&timestamp&&suffix > "/home/oracle/tosupport/test.log"

If it works you can try:

spool lfsdiag_&&dbname&&timestamp&&suffix > "/home/oracle/tosupport/"&&lfsdiag_&&dbname&&timestamp&&suffix
0
 

Author Comment

by:xoxomos
ID: 40497147
Cron line:
57 11 * * * /home/oracle/scripts/lfsdiag.sh > /home/oracle/tosupport/neils_test
spool line
spool lfsdiag_&&dbname&&timestamp&&suffix > "/home/oracle/tosupport/"&&lfsdiag_&&dbname&&timestamp&&suffix


This works....sortta :-)
The output comes with a mix of what i'm expecting and some errors .
When run throu cron
ASH WORST MINUTES FOR LOG FILE SYNC WAITS:

APPROACH: These are the minutes where the avg log file sync time
was the highest (in milliseconds).
order by 1,2
*
ERROR at line 8:
ORA-00936: missing expression

*******************************************************************
When run manually

ASH WORST MINUTES FOR LOG FILE SYNC WAITS:

APPROACH: These are the minutes where the avg log file sync time
was the highest (in milliseconds).

MINUTE          INST_ID EVENT                            TOTAL_WAIT_TIME      WAITS   AVG_TIME_WAITED
------------ ---------- ------------------------------ ----------------- ---------- -----------------
Dec11_2207            1 log file sync                          84745.374        275           308.165
Dec11_2216            1 log file sync                          27926.352         91           306.883
Dec11_2218            1 log file sync                          22417.809         80           280.223
 

I'm assuming it's another one of those differences depending on the environment the script is run in.
0
 

Author Closing Comment

by:xoxomos
ID: 40497149
Mil gracias
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After running Ubuntu some time, you will be asked to download updates for fixing bugs and security updates. All the packages you download replace the previous ones, except for the kernel, also called "linux-image". This is due to the fact that w…
If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question