Sathish David Kumar N
asked on
shell script output to log file
Hi ,
I have shell which is execute the mvn build . I want the execuation log into log file . log file description should be define in script itself
eg:
my sh file is
svn update
mvn clean install
i want the log to print in console will in txt file how to define in script itself
I have shell which is execute the mvn build . I want the execuation log into log file . log file description should be define in script itself
eg:
my sh file is
svn update
mvn clean install
i want the log to print in console will in txt file how to define in script itself
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You need to be careful as some utilities use stderr too, so
logfile=~/build.log
svn update >$logfile 2>&1
mvn clean install >>$logfile 2>&1
ASKER
what is difference between > and >>
ASKER
(svn update
mvn clean install ) >> a.txt
is that possible ??
mvn clean install ) >> a.txt
is that possible ??
One appends (>>) The other erases then appends
is that possible ??What does that mean? What's your intention?
>> means "append", whereas > means "new/overwrite"
The statement above won't work, maybe you meant something like this:
The statement above won't work, maybe you meant something like this:
svn update > a.txt && mvn clean install >> a.txt
Yes, the && is certainly a good idea as there presumably would be no point running mvn if the svn command failed ..?
An alternative would be to write:
exec > a.txt 2>&1
in your script. Everything that would have gone to stdout or stderr will instead go to a.txt, from that point in the script up to the end of the script This avoids having to redirect every command separately.
exec > a.txt 2>&1
in your script. Everything that would have gone to stdout or stderr will instead go to a.txt, from that point in the script up to the end of the script This avoids having to redirect every command separately.
svn update | logger
will do the trick.