LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to copy, then delete original of whatever log(s) that would help debug crashes... (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-copy-then-delete-original-of-whatever-log-s-that-would-help-debug-crashes-906007/)

BigSmellyMonkey 10-02-2011 12:41 AM

How to copy, then delete original of whatever log(s) that would help debug crashes...
 
First off, let's just say I'm writing this way too late at night... So bear with me.

I am very new to linux, although had a bit of experience with Unix back in the 90's. Used to program C... (as my bio says, I know just enough to be dangerous)

anyway, I'm running OpenSuse 11.3 (11.4 would crash immediately after install, that's a problem for another day)

I sometimes suddenly find myself back at the log in screen.

Sometimes I find everything completely frozen.

other times I've had a reboot.

Now, I know there is likely multiple causes, multiple issues etc...

In an attempt to figure out what is wrong,(I suspect RAM failure) I've been reviewing the /var/log/messages file.

This may or may not be the best place to look for the problem... But I would like to have the messages file copied to my home directory with a filename based on date.

currently, I would:

su
cp /var/log/messages /home/username/messages.snapshot
exit


I would append the date, and a number to represent 1st,2nd etc.

My reasoning, I would later be able to go back and review these, looking for the problem.

So, problem one, the permissions weren't set for username to view them

so before exiting root, I would add:
chown -c messages.snapshot --reference=/home/username/.bashrc

output:
changed ownership of 'messages.snapshot to username:users

My goal was to have in my .bashrc, each time I opened a konsole, which was usually have a crash to check what happened, I wanted it to do all that above...

copy the messages file
change ownership of new file
delete original(so each time I copied the file I was only looking at data since the last copy)

so as I worked toward this goal, I, in my utter brilliance, put in my username/.bashrc file,

su

so each time I opened a console it would prompt me for root's password

I then edited /root/.bashrc:
cp /var/log/messages /home/username/messages.snapshot
chown -c messages.snapshot --reference=/home/username/.bashrc


.... wait for it.... .... then I added ....
EXIT
to my /root/.bashrc

took me a while to figure out a way out of that one. Only way to edit roots .bashrc was to have su power, but to get that, .bashrc would run, and force me back to standard username's...

finally came up with <ALT-F2> kdesu kwrite /root/.bashrc

PHEW...

So, can someone point me toward a better way to make a copy of whatever log(s) you feel would be relevant, after a crash/freeze-up etc.

I know this was an insanely long post, but I had to go to that much detail, so I could tell you how stupid I was with the whole 'exit' in my root/.bashrc file.

(and yes, I am familiar with the term PEBKAC)

Thanks for any input.

I will be slow to respond, working way too much overtime, (which causes me to forget 90% of what I taught myself each time I get a chance to work on this)

I do appreciate some advice.

BM

zackwasa 10-02-2011 02:21 AM

Why would you copy the logs somewhere in the first place if you can simply login as root and check them out where they are? Also the logs are rotated so nothing seems to be lost.

RMI

BigSmellyMonkey 10-02-2011 07:36 AM

Well, my reason is that if I were to find the time to sit and review the logs, it would be much easier to find the problem if I had a dozen or so log files, where the end of each log file was the moment in time immediately after the crash/freeze-up.

I don't normally get more than a couple of hours in one shot to sit at my machine. And since I'm so new to linux, every time I sit down, I am learning. Learning a new OS, (and I don't mean learning how to use the GUI, but CLI) is difficult when you sometimes go weeks between 'lessons'.

I dunno, it might seem pointless to someone who understands what they are seeing every time they look at a log file. Or who has time to investigate each time something goes wrong.

Hope that makes sense.


I know there is probably a better method to debugging a problem...

BM


All times are GMT -5. The time now is 04:08 PM.