Solved

Location of output from cron job

Posted on 2014-12-11
7
92 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
  • 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 500 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
FTP File Transfer Failure 13 158
Assess most serious Linux privilege escalation bug 17 167
Installing VirtualBox in Fedora 25 Linux 2 359
High Bandwidth Usage 6 58
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…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

832 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