Jump to content

(Solved) Logs not working after modify syslog file.


Mr.xs

Recommended Posts

Hi,

I've got a problem with logs, so I wrote a script to modify syslog files but after script is done logs not working, they are freezed and nothing is written to them. This happend when I modify "syslog" file. However I notice that when I was using this script for only "syslog.2" and "syslog.1" without "syslog", everything was fine; the logs were working and the lines with error was deleted. So maybe someone can help me find out how to make logs work after script is done or maybe someone know where is the problem.

Maybe someone know how log works in unraid, how they are created, how they are splitted, what is the max size of syslog etc. and could explain it to me.

I've checked permission after modification and change it to exactly how they was before modify but it not work and logs were still freezed.

This is my script. I know it's kinda stupid but it might work for me.

#!/bin/bash
cd /var/log/
grep -v "input irq status" syslog.5 syslog.4 syslog.3 syslog.2 syslog.1 syslog >> tempfile 
diff <(tail -n 15 syslog) <(tail -n 15 tempfile) 1>/dev/null
if [[ $? == "0" ]]
then
  echo "The same"
  rm syslog.*
else
  echo "Not the same"
fi
diff <(tail -n 15 syslog) <(tail -n 15 tempfile)
if [[ $? == "0" ]]
then
  echo "The same"
  mv tempfile syslog
  rm tempfile
else
  echo "Not the same"
fi
echo "Done"

 

Link to comment

I've added two command to my script and it is working, so thanks for help.

#!/bin/bash
cd /var/log/
echo "Stoping log service..."
/etc/rc.d/rc.rsyslogd stop
grep -h -v "input irq status" syslog.5 syslog.4 syslog.3 syslog.2 syslog.1 syslog >> tempfile 
diff <(tail -n 15 syslog) <(tail -n 15 tempfile) 1>/dev/null
if [[ $? == "0" ]]
then
  echo "The same"
  rm syslog.*
else
  echo "Not the same"
fi
diff <(tail -n 15 syslog) <(tail -n 15 tempfile)
if [[ $? == "0" ]]
then
  echo "The same"
  mv tempfile syslog
else
  echo "Not the same"
fi
/etc/rc.d/rc.rsyslogd start
echo "Done"

 

Edited by Mr.xs
Link to comment
  • Mr.xs changed the title to (Solved) Logs not working after modify syslog file.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...