|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
Shell Script - Output background process command to file problem
Hi everyone,
Just started shell scripting for some simple tasks in Solaris 8. Here's my problem. I'm running a shell script from the crontab file to start and stop some services. There is a list of commands like the following Code:
#!/bin/csh $DIR/runthis stop >> logfile date >> logfile $DIR/runthis2 stop >>logfile date >> logfile $DIR/runthis start & date >> logfile $DIR/runthis2 start & date >> logfile Outputting the stop commands and date info to the logfile works fine. The problem is, I need to output the stdout of the commands issued in the background (&). If I put the append command (>>) after the ampersand (space or no space) with the logfile name, I get an "Invalid null char" error. I have searched the web to try and find out how you can append the output of a background process command to a file and there is nothing about it. I know the command outputs to the console because if I run it by itself, I get the output desired. Is there anyway to capture the output of a background process? Peace, Justin |
|
#2
|
|||
|
|||
|
I don't use csh very much, but try:
runthis start >> logfile & |
|
#3
|
|||
|
|||
|
Justin
csh on command line is an exceleent tool. csh in scripts is buggy, don't use it at all. what you want is: Code:
#!/bin/sh ( do-this do-that do-more & ) >logfile or '>>logfile' for append remember cron has a very restricted environment, so $DIR maybe NOT set. |
|
#4
|
|||
|
|||
|
guggach,
By aggregating the commands together, will the logfile still contain the output from each separate command or just the last one in the list? Justin |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Shell Script - Output background process command to file problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|