5

When I was trying to monitor the /var/log/secure or /var/log/message using watch command the output showed as /var/log/messages: Permission denied. Is it possible to monitor the /var/log/messages and /var/log/secure using watch command?

2
  • 2
    You cannot watch a file, you have to give it a command to run, like Ulrich Schwarz's answer with tail. For a file, you can just use tail -f instead of watch. Commented Apr 26, 2016 at 13:38
  • As an extra tip, some files like /var/log/secure may rotate while tailing them, causing tail -f to stop printing logs. To continue following even if the file is rotated, use tail -F. Commented Feb 8, 2018 at 10:10

2 Answers 2

6

Yes it is, but note that regular users don't have permission to read /var/log/messages and /var/log/secure.

sudo watch tail /var/log/messages 

worked fine here when I tried.

2
  • Hi Ulrich Schwarz, im using centos 6.7 , i used root account rather than normal user account, i got the error message when i was using root account only. Commented Apr 26, 2016 at 13:19
  • Note that most sensible distros will make log files owned root adm and mode 0640 so anyone in the adm group can read them. If so, adduser regularjoe adm will allow regularjoe to read them once he logs in again. Commented Jul 23, 2016 at 18:01
2

You only have to issue:

sudo tail -f /var/log/messages

This will continuously add the latest line to the screen or file.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.