Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Fri May 03, 2013 10:11 pm 
Offline
Newbie

Joined: Fri May 03, 2013 10:01 pm
Posts: 2
Hi,
I have deployed my Linode with stackscript without problem, but I'm looking for a way to log all the console output from the stackscript to a file, so I can review the log after the deploy finished.

I have been trying tools like "script", "ttylog"(from cpanm), but they seems not work on logging the output from hvc0.
I also tried "lastcomm"(from acct) which can list the commands have been executed, but it just not exactly what I need.

So any idea?
Thanks.


Top
   
PostPosted: Sat May 04, 2013 12:13 am 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
Somewhere in the stackscript before the output you want to capture, you can add the following line:
Code:
exec >/path/to/log/file


This will capture standard output. If you want to capture standard error as well, use
Code:
exec >/path/to/log/file 2>&1


Edit: the above will clobber the log file if it already exists. To append to the file instead, use
Code:
exec >>/path/to/log/file 2>&1


Top
   
PostPosted: Sat May 04, 2013 6:08 pm 
Offline
Newbie

Joined: Fri May 03, 2013 10:01 pm
Posts: 2
Vance,
I knew the way you're talking about, but I'm looking for the way to save the console message without touch the original commands.
Thanks.


Top
   
PostPosted: Sat May 04, 2013 6:49 pm 
Offline
Senior Member
User avatar

Joined: Sun Dec 27, 2009 11:12 pm
Posts: 1038
Location: Colorado, USA
Yeah Vance, it needs to be a magic way, geeeesh, didn't you learn anything from those 8 nauseating Harry Potter movies? (ok, the first three were kind of cute, then the actors/actresses turned 35 and kind of spoiled the whole suspend disbelief thing).

Expecting people to add ONE WHOLE LINE to an existing script - what world do you live in???

_________________
Either provide enough details for people to help, or sit back and listen to the crickets chirp.
Security thru obscurity is a myth - and really really annoying.


Top
   
PostPosted: Mon Oct 26, 2015 10:25 am 
Offline
Junior Member

Joined: Fri Jun 02, 2006 10:02 am
Posts: 26
Old thread but it comes up highest in search results when I was trying to achieve the same.

Here is what I am using in a StackScript to send stdout and stderr to a log file and also to console (so the progress can be viewed in lish):

Code:
# send stdout and stderr to both console and log file
>/root/stackscript.log
exec >  >(tee -a /root/stackscript.log)
exec 2> >(tee -a /root/stackscript.log >&2)


This may help someone else.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group