LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-07-2010, 02:04 AM   #1
raulapati
Member
 
Registered: May 2010
Posts: 51

Rep: Reputation: 0
Question how to creat a log file


can any body tell me how to creat a log file in linux...when i run the script the details must go to log file...
 
Old 10-07-2010, 02:10 AM   #2
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
Which script do you want to run? Shell script, Perl, Python, ...
 
Old 10-07-2010, 02:16 AM   #3
raulapati
Member
 
Registered: May 2010
Posts: 51

Original Poster
Rep: Reputation: 0
shell script
 
Old 10-07-2010, 02:20 AM   #4
raulapati
Member
 
Registered: May 2010
Posts: 51

Original Poster
Rep: Reputation: 0
can any body tell me how to creat a log file in linux...when i run the script the details must go to log file in shell script
 
Old 10-07-2010, 02:22 AM   #5
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 624

Rep: Reputation: 64
You can do this with this command:

Quote:
#./script.sh >> /var/log/newlog
Then the output will be redirected to the file named newlog.
 
Old 10-07-2010, 02:33 AM   #6
raulapati
Member
 
Registered: May 2010
Posts: 51

Original Poster
Rep: Reputation: 0
..once i run the script the data must output to logfile...though i terminate the script the data must go to the log file..
 
Old 10-07-2010, 03:14 AM   #7
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
Post your shell script and give us an example about 'data' which you want append to log file.
 
Old 10-07-2010, 05:12 AM   #8
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by raulapati View Post
..once i run the script the data must output to logfile...though i terminate the script the data must go to the log file..
What's wrong with the solution in post #5 ?
 
Old 10-07-2010, 05:28 AM   #9
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
I'm thinking that maybe he needs a logging system or function or a redirection inside the script using exec.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] rear file names to creat a comma delimited file GRS63 Linux - Software 7 02-04-2011 12:40 AM
Fail to creat new file in vim taureanyang Linux - Software 1 07-22-2005 12:32 AM
how is it possible to creat a virus when making a PDF file??? Lleb_KCir Linux - Software 7 05-11-2005 05:44 PM
Can't creat file in /var/log Joe_Zhu Linux - Software 1 08-18-2004 05:12 AM
horde can't creat log file Joe_Zhu Linux - Software 2 08-05-2004 10:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration