Solved

Location of output from cron job

Posted on 2014-12-11
7
96 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux patching 4 73
how to figure out and set up JAVA_HOME value in red hat linux 7 208
vCenter 6 Virtual Appliance and e2fsck and Superblock Errors 17 224
Ubuntu vs. Debian 4 118
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…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

830 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