LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-17-2009, 07:59 PM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 31
last log


I know the command "last" can show the user login record , so now when I use this command , it shows the user login record in this half year ( I didn't clear it for half year ) , can advise if I want clear the old record so that it only show the record from 1-feb-09 ( that mean clear the record before 1-feb-09 ) , what can i do ?
 
Old 02-17-2009, 09:04 PM   #2
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
Find out what file that database is located in, use google. Then you could completely clear it by

echo "" > database.txt

or you could run a special script delete all the records except the ones in feb 09. Or depending on the size of the file, run

ls -l database.txt

if the size of the file is a lot less that your ram, you could just try running kedit, then open the file and edit it manually. The filename probably isnt' called database.txt, just using that as an example.
 
Old 02-17-2009, 09:48 PM   #3
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by trist007 View Post
Find out what file that database is located in, use google. Then you could completely clear it by

echo "" > database.txt

or you could run a special script delete all the records except the ones in feb 09. Or depending on the size of the file, run

ls -l database.txt

if the size of the file is a lot less that your ram, you could just try running kedit, then open the file and edit it manually. The filename probably isnt' called database.txt, just using that as an example.

I find the lastlog , you mean try echo lastlog > database.txt ? I tried it but not work...


thx
 
Old 02-17-2009, 09:52 PM   #4
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
to clear the lastlog of all entries do

echo "" > lastlog
 
Old 02-19-2009, 01:03 AM   #5
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by trist007 View Post
to clear the lastlog of all entries do

echo "" > lastlog
thx reply ,

I am not want to clear it , I just want to erase the data before 1-feb , can advise what can i do ? thx
 
Old 02-19-2009, 01:50 AM   #6
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 31
I know I can use last -f wtmp to export the file to text , then I can modify it , but how can I import back it to current wtmp ?
 
Old 02-19-2009, 02:23 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can truncate the file wtmp using the tail command, even if it is a binary file. First do a backup of the original wtmp file somewhere. Then you can try the tail command choosing an arbitrary number of lines (e.g. 100) redirecting the output to a file. Then substitute the original wtmp with the newly created file and try the last command. You can adjust the number of lines to truncate until you reach the 1st of February as the first record in the file. Unfortunately there is no correspondence between the number of lines in the output of last and the number of line in the wtmp file, so that you have to retry until you reach the desired size.

To avoid this handy method in the future, you can setup a logrotate script to manage the wtmp file, for example by rotating it once a month.
 
Old 04-30-2009, 01:35 AM   #8
skipdashu
LQ Newbie
 
Registered: Apr 2009
Location: República de Tejas, Centro
Distribution: Ubunut, Xubuntu, Dotsch/UX
Posts: 19

Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
To avoid this handy method in the future, you can setup a logrotate script to manage the wtmp file, for example by rotating it once a month.
Glad you brought this up. I have a file called boinc.log in /home/boinc/BOINC/

I created a file called boinc in /etc/logrotate.d/

The file looks like this:

Code:
/home/boinc/BOINC/boinc.log {
  daily
  compress
  missingok
  notifempty
}
For this machine the logrotate.conf is:

Code:
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 3 weeks worth of backlogs, SRG 2009/4
rotate 3

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0660 root utmp
    rotate 1
}
My problem is that boinc.log is not rotating but I don't see any problem in the config files. Is there something else I need to do?

Last edited by skipdashu; 05-01-2009 at 01:15 AM.
 
Old 04-30-2009, 02:13 AM   #9
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
It looks correct. Try to manually run logrotate (usually it runs automatically from the daily crontab):
Code:
/usr/sbin/logrotate /etc/logrotate.conf
You can try the -f option, too. According to the man page of logrotate:
Code:
-f, --force
      Tells  logrotate to force the rotation, even if it doesn’t think this is necessary.  Sometimes
      this is useful after adding new entries to logrotate, or if old log files have been removed by
      hand, as the new files will be created, and logging will continue correctly.
 
Old 05-01-2009, 01:20 AM   #10
skipdashu
LQ Newbie
 
Registered: Apr 2009
Location: República de Tejas, Centro
Distribution: Ubunut, Xubuntu, Dotsch/UX
Posts: 19

Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
It looks correct. Try to manually run logrotate (usually it runs automatically from the daily crontab):
Code:
/usr/sbin/logrotate /etc/logrotate.conf
You can try the -f option, too. According to the man page of logrotate:
Code:
-f, --force
      Tells  logrotate to force the rotation, even if it doesn’t think this is necessary.  Sometimes
      this is useful after adding new entries to logrotate, or if old log files have been removed by
      hand, as the new files will be created, and logging will continue correctly.
Yup, just needed a kick in the butt... I ubuntuized the command (lol) to:
Code:
sudo logrotate -f /etc/logrotate.conf
Thanx much,
Skip
 
Old 05-01-2009, 02:35 AM   #11
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
He he... "ubuntuized the command" is really nice!
 
  


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
the significance and name of the 5th column of /var/log/auth.log (ubuntu server)? CoffeeKing!!! Linux - Security 4 02-05-2009 07:32 AM
What the %$#@ is pam_unix (cron:session) doing every ten minutes? (/var/log/auth.log) CoffeeKing!!! Linux - Security 3 02-05-2009 07:07 AM
/var/log/auth.log doens't have correct date and hostname (Solution) alfmarius Linux - Newbie 0 10-07-2008 06:09 AM
Can Samhain log my entries in /var/log/secure and /var/log/mesage to a central server abefroman Linux - Software 2 04-13-2008 04:13 PM
Opennms Logs - where are web.log, web_rtc.log and webauth.log referenced? not_much_of_a_guru Linux - Networking 0 07-12-2006 10:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:28 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