I have an apache access log with the below format and I’m trying to use the awk command to filter out the requests by the last 15 minutes. It works fine when there are entries but returns everything when there are none found in the last 15 minutes. Access log format Answer It’s not possible to compare date directly in
Tag: logging
How to log every single command executed from shell script
I am trying to find a way to record every single command that is executed by any user on the system. Things that I have came across earlier. It is possible to view shell commands executed from the terminal using ~/.bashrc_history file. There is a catch here, It logs only those commands which were executed interactively from bash shell/terminal. This
spawn strace command with Node.js child_process
Since I’m not happy with this approach and I got no answers, I’m trying another method to track the output of an already running program. I based this code on this Unix Stack Exchange and what I’m trying to do is just retrieve the log information of a program that is already running. Obs: to use strace without sudo you
Options for getting logs in kubernetes pods
Have few developer logs in kubernetes pods, what is the best method to get the logs for the developers to see it. Any specific tools that we can use? I have the option of graylog, but not sure if that can be customized to get the developer logs into it. Answer The most basic method would be to simply use
How to keep service script output from clogging up “messages”
I have a service on Centos7 that runs a script in /usr/local/sbin/restarthelp2.sh and outputs a tunnel check by checking the status of network connection. The output of this ends up in /var/log/messages and makes the file huge. I already have the output being sent to its own log file, how do I keep the output results from the script/service out
how to customize ssh log?
Goals of my ask: Implement a fail2ban which ban user. (For this I have a solution) Work environment: I connect to my machines with ssh-key protect with a password When a user type a wrong password for his ssh-key thrice I want to ban it for prevent attack Fail2ban parsed logs in /var/log/messages. Actually I have enable LogLevel DEBUG2 on
How to remove/modify syslogd message’s header?
I’m currently use the syslogd of busybox for logging some information. However, I’m unable to modify the message’s header. I log the message like this: And I got this output: I want to replace message’s header with epoch time format like this: Or is there any way to completely remove the message’s header so I could manually add the epoch
How to capture the output of a top command (for a specific process that will die) in a file
I have a process MYPID=18686 that I am monitoring with top. When the process dies, the output file is empty. My end goal is just to record cpu usage over the lifetime of that process. Specifying -n 1000 -d 5 is a cheap workaround that runs top for the expected lifetime of the process. The tail -1 was to eliminate
How to log to /var/log/mail.log using rsyslogd?
I am currently playing around with logging under Linux. I have made the following very simple test application (in plain C): This “application” compiles, and when I execute it, it generates an entry in /var/log/syslog, but no entry in /var/log/mail.log and no entry in /var/log/mail.err. Could somebody please explain why? I am using rsyslogd on the test machine; this is
No activity on server with logging every 5 seconds
Recently I have notices that log files on my server grow faster than I was expecting. After a quick look I have realized that it is wtmp what aggressively is taking my disk space. Using utmpdump command (see below) I found out that every 5 seconds new 3 or 4 logs are recorded. There is no load on the server: