RanRag RanRag 4, 6 6 gold badges 18 18 silver badges 15 15 bronze badges. Add a comment. Active Oldest Votes. I solved the problem. Improve this answer. There are many implementations. The most prevalent implementation is Vixie cron. I am the current, not the original author of another. I'm glad you found a solution that works for you; just thought it was worth pointing out there are many variables that could affect whether it works for others.
Danijel : This should help serverfault. Show 1 more comment. For example If your user has shell csh or zsh or ksh set for his login shell. Where does crond emit error messages for a syntax error? Ramces Gonzalez Ramces Gonzalez 11 3 3 bronze badges. Sign up or log in Sign up using Google. Asked 10 years, 6 months ago.
Active 8 months ago. Viewed 1. Improve this question. Rayne Rayne 13k 15 15 gold badges 37 37 silver badges 48 48 bronze badges.
Add a comment. Active Oldest Votes. Improve this answer. If you need to redirect that too, the shell cannot help you, but expect can. Kinda obvious but worth mentioning. Show 7 more comments. Tripp Kinetics 4, 2 2 gold badges 21 21 silver badges 35 35 bronze badges. Bryan Agee Bryan Agee 4, 3 3 gold badges 24 24 silver badges 41 41 bronze badges. In a portable shell script and if you don't need portability, why are you writing a shell script?
To get the output on the console AND in a file file. Sagar Jain Sagar Jain 6, 10 10 gold badges 42 42 silver badges 74 74 bronze badges. Indrajeet Gour Indrajeet Gour 3, 3 3 gold badges 33 33 silver badges 49 49 bronze badges. Which shell? When I use the above, it prints the error messages in plain text, minus the formatting.
Is there any way to retain on-screen formatting and get the output both stdout and stderr in a file as well? Show 4 more comments. Show 5 more comments. To the author of the original post, It depends what you need to achieve. Create file descriptors FDs 3 and 4 and point to the same "location" as 1 and 2 respectively.
Changing file descriptor 1 doesn't affect file descriptor 3 from now on. Now, file descriptors 3 and 4 point to standard output and standard error respectively. These will be used as real terminal standard output and standard error. At the same time it copies the same input to file descriptor 3 the terminal the second part, very similar, is about doing the same trick for standard error and file descriptors 2 and 4. That's true although it depends on intentions.
My approach is to always create a unique and timestamped log file. The other is to append. Both ways are 'logrotateable'. I prefer separate files which require less parsing but as I said, whatever makes your boat floating : — quizac. Your second solution is informative, but what's with all the cleanup code? It doesn't seem relevant, and if so, only muddles an otherwise good example.
I like it better with the cleanup code. It might be a bit of distraction from the core example, but stripping it would make the example incomplete. The net is already full of examples without error handling, or at least a friendly note that it still needs about a hundred lines of code to make is safe to use. I wanted to elaborate on clean-up code. So, once the main process dies they become inherited by init[1].
They will not become zombies defunc. The clean-up code makes sure that all background tasks are killed, if main script dies. It also applies to any other process which might have been created and running in background.
Mark Mark. Finally, I'd note that there is a simpler way to do this: From section 3. One generates output and the other does not!
Evan Rosica Evan Rosica 1, 11 11 silver badges 20 20 bronze badges. File descriptors 0, 1, 2 are just offsets into a table. I use the term dup because that is the system call that is used to duplicate the file descriptor.
This is actually very important, and less known. Good call. BTW, this didn't work for me logfile is empty. Instead I got it working using stackoverflow. Fernando Fabreti Fernando Fabreti 3, 3 3 gold badges 26 26 silver badges 32 32 bronze badges. Sorry to hear that.
0コメント