- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: output redirection not working
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2005 06:00 PM
тАО03-22-2005 06:00 PM
====
#!/usr/bin/csh
./perlscript options options >>& /tmp/perlscript.log
====
I execute the csh script in cron like this:
xx * * * * csh -c '/directory/csh_perlscript.sh' >> /tmp/perlscript.log 2>&1
or directly from a terminal like this:
./csh_perlscript.sh >>& /tmp/perlscript.log
What I notice is that the output of the csh_perlscript is sent to the perlscript.log but the outout of the perlscript itself is not sent to the log file.
What could be wrong? Sometimes it works but it takes a very long time before the file is updated.
Thanks in advance!
Kenneth
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2005 06:12 PM
тАО03-22-2005 06:12 PM
Re: output redirection not working
> or directly from a terminal like this:
>
> ./csh_perlscript.sh >>& /tmp/perlscript.log
Change that to:
./csh_perlscript.sh >> /tmp/perlscript.log 2>&1
Same as the way you used in cron.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2005 06:14 PM
тАО03-22-2005 06:14 PM
Re: output redirection not working
./perlscript options options >>& /tmp/perlscript.log
and try it out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2005 08:04 PM
тАО03-22-2005 08:04 PM
Re: output redirection not working
After more observation, the redirection seems to be working but the file is not being updated in real time. It is as if it is waiting for a certain memory buffer to fill up before it dumps the contents to the logfile.
How can I tune this so that the output is immediately dumped into the log file so I could monitor the output in real time.
Thanks in advance!
Kenneth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2005 04:54 PM
тАО03-27-2005 04:54 PM
Re: output redirection not working
Thanks for the tip. I was just checking out the same with a simple script here and it works pretty fine, maybe you are doing something within your perl script which take time to generate the output. Did you try running your script with a csh -x?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2005 05:04 PM
тАО03-27-2005 05:04 PM
Re: output redirection not working
If I ran the perl script directly from within a csh enviroment, the output is immediately sent to the screen.
Now I'm wandering if there is some kernel tuning parameter needed or maybe the server is just so heavily loaded. The perl script is doing an sql query to an oracle server.
Thanks for the update.
Kenneth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2005 05:14 PM
тАО03-27-2005 05:14 PM
Re: output redirection not working
Try runnning the script with
csh -x <scriptname>
This might give you an idea as to where your script is taking up the most time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2005 10:07 AM
тАО03-28-2005 10:07 AM
Re: output redirection not working
csh -c '/directory/csh_perlscript.sh >> /tmp/perlscript.log 2>&1'
Remember that cronjobs are run with the standard /bin/sh and as such your "csh" is being called from "sh". Putting the quotes around the whole line will force the output redirection to be processed by "csh" and not "sh".
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2005 12:36 PM
тАО03-28-2005 12:36 PM
Re: output redirection not working
I have a perl script named perlscript.pl that has a multi argument input. It is being executed inside a csh enviroment.
When I directly run the script through a terminal, it outputs the result of an sql query to the screem almost immediately.
When I try to redirect the output to a log file, it is taking considerable time for the log file to be updated, sometimes it takes up to 10 minutes or more.
The perl script is run through cron but as it contains a long argument list, I also placed it inside a csh script. The cron runs the csh script. The csh script runs the cron.
My problem is actually when redirecting the output of the perl script itself. The output logfile is not being updated in realtime although the script is working normally.
Hope you guys can keep the suggestions and possible solutions coming!
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2005 01:50 AM
тАО03-29-2005 01:50 AM
SolutionYou can force perl to flush it's buffer after every print line, by setting $|=1;
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2005 08:23 PM
тАО03-29-2005 08:23 PM
Re: output redirection not working
Thanks! That did it. I thought it was the csh shell whose bufferring the input to the logfile and never occurred that it was perl who was bufferring its output.
Again many thanks!
Ken