Route the logs to different file other than nohup.out


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Route the logs to different file other than nohup.out
# 1  
Old 03-13-2008
Route the logs to different file other than nohup.out

Hi guys

Right now the standard out and standard err are going to nohup.out file
I wanted to route to some other name specific files so that it will be easy to research the logs

Example

I have this line in my script
nohup execute receiptLoaderStart &
which is routing the logs to nohup.out
As most of the scripts are routing the standard err to nohup.out I am having trouble to research the logs
I wanted to route the logs to nohup_sumarylogfile
I have tried to nohup execute receiptLoaderStart & > nohup_sumarylogfile
but some how it's not routing to nohup_sumarylogfile
Can anybody help me out of this

Thanks in advance
# 2  
Old 03-13-2008
How about:
nohup execute receiptLoaderStart > nohup_sumarylogfile 2>&1 &
# 3  
Old 03-13-2008
Thanks

It worked for me

Thanks
Pinky
# 4  
Old 03-13-2008
One more doubt on this one
How can I make datewise backup of log files on nohup_summarylogfile

I wanted everyday to be a new log file appended by the date like

nohup_summarylogfile20080313


Thanks in advance for the help
Pinky
# 5  
Old 03-14-2008
If your job is restarted every day you can use a variable in the logfile name (check the manpage for the format on "date", i have no manpage at hand writing this):

Code:
date="$(date +'%Y%m%d')"
nohup /your/job >logfile.${date} 2>&1 &

If the job runs permanently you will have to create a job which copies the contents of the logfile to another file and then clears the logfile. This job can be run from cron daily. The following is just a sketch:

Code:
#! /bin/ksh

date="$(date +'%Y%m%d')"

if [ -w /the/file/to/trim ] ; then
     cat /the/file/to/trim > /some/path/logfile.${date}
     cat /dev/null > /the/file/to/trim
fi

exit 0

The reason why i do not delete the file but overwrite it with an empty stream ("cat /dev/null") is to preserve the inode number. Some processes do not like having the inode numbers of files they are writing to changed.

I hope this helps.

bakunin
# 6  
Old 03-14-2008
Thanks a lot for the solution it partially worked for me
I appreciate all the help

My script has is
nohup execute receiptLoaderStart > nohup_sumarylogfile 2>&1 &

that means I have nohup_sumarylogfile but I don't see any time stamp inside the file like for every new action I wanted to add time stamp
inside the log file

Can anybody help me

Thanks
Pinky
# 7  
Old 03-14-2008
Well, inside the log file only the application writes. If you want a timestamp there you will have to configure the application (receiptLoaderStart) to write one. If the application cannot do this you can't do it either without changing the application (by reprogramming, ...).

Wht you can do is, depending on the frequency of the logfile being written: write a small shell script that prints only a time stamp and make it a cron job. Have it write every hour a line with the time to the logfile. You will then know which part of the logfile was written in which hour of the day:

Code:
<..... your normal log content .....>
------------[15:00]------------------
<..... your normal log content .....>
<..... your normal log content .....>
------------[16:00]------------------
... etc.

This is not exactly what you want, but at least some approximation. The script would look like:

[code]#! /bin/ksh

print - "------------[$(date +'%H:%M')]----------" >> /path/to/logfile

bakunin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies

2. Shell Programming and Scripting

Saving nohup output to a file other than nohup.out

Shell : bash OS : Oracle Linux 6.4 I want to save the ouput of a nohup command to file other than nohup.out . Below are my 3 attempts. For both Attempt1 and Attempt2 , the redirection logs the output correctly to the output file. But I get the error "ignoring input and redirecting stderr to... (7 Replies)
Discussion started by: kraljic
7 Replies

3. Shell Programming and Scripting

grep from the nohup.out file

Hi, I have one shell script, which run another one script inside in nohup mode. I want to search one string from the nohup.out file in the same shell script itself .Can anyone help me?? Please find the code below: total_ear=`cd ear ; ls *.ear | wc -l | tr -d ' '` for ear in `cd ear ; ls... (1 Reply)
Discussion started by: ckchelladurai
1 Replies

4. UNIX for Dummies Questions & Answers

How to grep string from nohup.out file

Hi, I have one shell script, which run another one script inside in nohup mode. I want to search one string from the nohyup.out file in the same mail shell script itself .Can anyone help me?? Please find the code below: total_ear=`cd ear ; ls *.ear | wc -l | tr -d ' '` for ear in `cd ear ; ls... (0 Replies)
Discussion started by: ckchelladurai
0 Replies

5. Red Hat

Comment in static route file

Hi all, is it possible to add a comment starting with "#" (with vi for example) to the static route file in: /etc/sysconfig/network-scripts/route* Are you aware of any problems this can cause after a network restart? Thanks, Evan (1 Reply)
Discussion started by: Evan
1 Replies

6. Shell Programming and Scripting

output nohup file containg the PID

Hi to everybody. Is it possible to nohup a process and redirect the output to a file containing the PID? E.g. if nohup filename > out.nohup associate the PID=8074 to filename, is it possible to call the output file something like out_8074.nohup instead of out.nohup? By this way it would... (0 Replies)
Discussion started by: plsrn
0 Replies

7. OS X (Apple)

What's The Easiest Route To Creating A Unix Executable File for Terminal?

I've seen the executable open in the application OmniOutliner, can I create an executable with this app? I'd like to be able to create the unix executable and insert it into terminal, but I'm not sure if the Omni app will allow me to create it. Any one have any ideas or possibly familiar with... (10 Replies)
Discussion started by: unimachead
10 Replies

8. UNIX for Dummies Questions & Answers

How to route error to log file in unix

Hey Every one I have a find statement which find the files and deletes them find /web/local/orderlink/batchmanaged01/scripts/SMOappLogs/log -name 'orderlink.log.*' -type f -mtime +$10-exec rm -f {} \; This statement if finds a file at the given location it will delete the files but if it... (4 Replies)
Discussion started by: pinky
4 Replies

9. UNIX for Dummies Questions & Answers

I want to copy the text output from a 'nohup.out' file.

Hello, I have a nohup.out file that, when executed, outputs a spreadsheet file with four-to-seven columns of number. I want to copy this output (in its entirety), so that I could then paste it on excel@ , or Notepad@. Please help, thanks. (3 Replies)
Discussion started by: Iamthe great
3 Replies

10. Shell Programming and Scripting

capture nohup log file

Hi, I am running my script using nohup, but I am not able to capture the log file for that process could naybody please help... Here is what I am doing.... nohup ./script & 1>/home/user1/log.txt but I am not able to capture the log.....Is there anyother way I can capture the log... (2 Replies)
Discussion started by: mgirinath
2 Replies
Login or Register to Ask a Question