Mr.xs Posted August 17, 2021 Share Posted August 17, 2021 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" Quote Link to comment
trurl Posted August 17, 2021 Share Posted August 17, 2021 The syslog process has the current syslog file open all the time, and anything you try to do to that file while syslog process has it open is probably breaking the syslog process. The "rotated" syslog.1, etc. are safe to work on since they aren't open any more. Quote Link to comment
Mr.xs Posted August 17, 2021 Author Share Posted August 17, 2021 (edited) 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 August 17, 2021 by Mr.xs Quote Link to comment
Recommended Posts
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.