![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems . |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| delete n last lines of a file | ncatdesigner | Shell Programming and Scripting | 7 | 05-17-2008 07:07 AM |
| delete first 100 lines from a file | salaathi | SUN Solaris | 3 | 11-15-2007 12:01 AM |
| delete the lines from file | sameersam | Shell Programming and Scripting | 2 | 04-03-2006 10:32 PM |
| Delete lines in a file | umal | Shell Programming and Scripting | 6 | 02-08-2006 09:08 AM |
| delete all lines in file | strok | UNIX for Dummies Questions & Answers | 6 | 03-11-2002 06:27 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
delete first 100 lines rather than zero out of file
Hi experts,
in my solaris 9 the file- /var/adm/messeages growin too first. by 24 hours 40MB. And always giving the below messages-- bash-2.05# tail -f messages Nov 9 16:35:38 ME1 last message repeated 1 time Nov 9 16:35:38 ME1 ftpd[16392]: [ID 476795 daemon.error] wtmpx /var/adm/wtmpx No such file or directory Nov 9 16:35:38 ME1 last message repeated 1 time Nov 9 16:35:38 ME1 ftpd[16393]: [ID 476795 daemon.error] wtmpx /var/adm/wtmpx No such file or directory Nov 9 16:35:38 MEMM1 last message repeated 1 time --- i then tried with #touch wtmpx. Although the above messages stops but wtmpx grows more faster than file 'messages'. so i again delete 'wtmpx'. For your information this SUN server uses for various types of FTP everyminutes. So, far i know 'wtmpx' files logs the user access. that is why it grows too fast. I now plan to adjust a script in crontab which will delete first 100 lines from messages after 2/3 days. But i don't know how to implement the script. Could anyone help me?? Cheers purple |
| Forum Sponsor | ||
|
|
|
|||
|
The following command will delete the first 100 lines from your wtmpx file:
$ sed '1,100d' wtmpx However, if your wtmpx file grows by 40MB's every 24 hours I reckon 100 lines will not make much of a difference. Do a cat wtmpx |wc -l to count the lines and then decide how many lines you should delete to shrink the file size sufficiently. |
|
|||
|
Hi soliberus,
I tried to delete first 100 lines of file messages with command # sed '1,100d' messages. But it is not working. Please see below. bash-2.05# cat messages |wc -l 36948 bash-2.05# sed '1,100d' messages bash-2.05# cat messages |wc -l 36949 bash-2.05# And about 'wtmpx'- the file is not understanble to me bash-2.05# tail -f wtmpx bgwftpftp10010'G4)192.168.210.35bgwftpftp10010G4)192.168.210.35bgwftpftp10012'G4)192.168.210.35bgwft pftp10011'4)192.168.210.42bgwftpftp10012G4)192.168.210.35bgwftpftp100114)192.168.210.42bgwftpftp1001 3'G4*192.168.210.35bgwftpftp10013G4*192.168.210.35bgwftpftp10014'G4+192.168.210.42bgwftpftp10014G4+1 92.168.210.42bgwftpftp10015'G4+192.168.210.37bgwftpftp10015G4+192.168.210.37bgwftpftp10016' G4+192.168.210.40bgwftpftp10016'G4+192.168.210.40bgwftpftp10017'!G4+192.168.210 bash-2.05# cat wtmpx |wc -l 13 Though it shows only 13 lines and lines are growing slowly but File size is growing to much fast. |
|
|||
|
Ooops, I didn't give you the full script.
It should look something like this: sed '1,100d' messages > messages.tmp cat messages.tmp > messages rm message.tmp I'm sure this is not the most effective way of truncating a file, but it works. |
|
|||
|
delete first 100 lines rather than zero out of file
Hi all, i told you i m getting mainly prob with frequently growing 2 files /var/adm/messages OR /var/adm/wtmpx.
I got a solution for overgrowing wtmpx. Below is the line need to put in cronjob. it will empty wtmpx file after every 30 minutes. 30 * * * * su - root -c "cat /dev/null > /var/adm/wtmpx" > /dev/null 2>&1 I get it from sun solaris 8. Although i am using solaris 9 but hope line should work it also . However, can anyone tell me what is the value here "root -c" and "2>&1"?? Quote:
|
|||
| Google UNIX.COM |