title: Fetch last one hour entries from the apache domlog
body: <p>I have gone through some other search results already, like <a href="https://stackoverflow.com/questions/21821968/shell-script-to-get-exception-from-logs-for-last-one-hour">link1</a> <a href="https://unix.stackexchange.com/questions/417986/how-to-extract-log-entries-from-the-last-hour">link2</a> but I could not make mine working yet for seeing log from the Apache domlogs for the last one hour to the current time.</p>
  
  <p>Portion of log is:</p>
  
  <pre><code>54.X.X.X - - [08/Jan/2020:02:59:12 +0100] "GET /robots.txt HTTP/1.1" 404 - "-" "Pandalytics/1.0 (https://domainsbot.com/pandalytics/)"
  54.X.X.X - - [08/Jan/2020:02:59:12 +0100] "GET / HTTP/1.1" 200 810 "-" "Pandalytics/1.0 (https://domainsbot.com/pandalytics/)"
  54.X.X.X - - [08/Jan/2020:20:08:09 +0100] "GET /wp-login.php HTTP/1.1" 404 16 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
  54.X.X.X - - [08/Jan/2020:22:33:20 +0100] "GET /robots.txt HTTP/1.1" 404 - "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
  54.X.X.X - - [08/Jan/2020:22:33:47 +0100] "GET / HTTP/1.1" 200 810 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
  54.X.X.X - - [08/Jan/2020:22:35:22 +0100] "GET /robots.txt HTTP/1.1" 404 - "-" "msnbot/2.0b (+http://search.msn.com/msnbot.htm)"
  54.X.X.X - - [09/Jan/2020:08:07:10 +0100] "GET / HTTP/1.1" 200 810 "https://www.bing.com" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
  54.X.X.X - - [09/Jan/2020:08:08:37 +0100] "GET /robots.txt HTTP/1.1" 404 - "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
  54.X.X.X - - [09/Jan/2020:08:08:37 +0100] "GET / HTTP/1.1" 200 810 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
  54.X.X.X - - [09/Jan/2020:19:12:56 +0100] "GET /wp-login.php HTTP/1.1" 404 16 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36"
  54.X.X.X - - [09/Jan/2020:19:13:34 +0100] "GET /robots.txt HTTP/1.1" 404 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36"
  54.X.X.X - - [10/Jan/2020:03:25:25 +0100] "GET /.git/config HTTP/1.1" 404 - "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
  </code></pre>
  
  <p>Its date and time pattern in the log is:  </p>
  
  <pre><code># date +%d/%b/%Y:%H:%M:%S
  10/Jan/2020:15:11:43
  </code></pre>
  
  <p>and from the last one hour:</p>
  
  <pre><code># date -d -1hour +%d/%b/%Y:%H:%M:%S
  10/Jan/2020:14:11:13
  </code></pre>
  
  <p>I tried something like:</p>
  
  <pre><code>d1=$(date -d -1hour +%d/%b/%Y:%H:%M:%S)
  d2=$(date +%d/%b/%Y:%H:%M:%S)
  awk -v d1="$d1" -v d2="$d2" '$0 &gt; d1 &amp;&amp; $0 &lt; d2 || $0 ~ d2' domlog.log
  </code></pre>
  
  <p>But returns nothing. I tried several other ways as well.</p>
  
  <p>At the same time, the same approach is working fine for the system log /var/log/messages</p>
  
  <p>Its pattern example:</p>
  
  <pre><code># d1=$(date -d -1hour +%b" "%d" "%H:%M:%S);d2=$(date  +%b" "%d" "%H:%M:%S);awk -v d1="$d1" -v d2="$d2" '$0 &gt; d1 &amp;&amp; $0 &lt; d2 || $0 ~ d2' /var/log/messages
  Jan 10 14:15:01 cpanel systemd: Started Session 11085 of user root.
  Jan 10 14:15:01 cpanel systemd: Started Session 11086 of user root.
  Jan 10 14:15:08 cpanel pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
  Jan 10 14:15:08 cpanel pure-ftpd: (?@127.0.0.1) [INFO] __cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse is now logged in
  Jan 10 14:15:08 cpanel pure-ftpd: (__cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse@127.0.0.1) [INFO] Logout.
  Jan 10 14:20:01 cpanel systemd: Started Session 11087 of user root.
  Jan 10 14:20:01 cpanel systemd: Started Session 11088 of user root.
  Jan 10 14:20:01 cpanel systemd: Started Session 11089 of user root.
  Jan 10 14:20:10 cpanel pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
  Jan 10 14:20:10 cpanel pure-ftpd: (?@127.0.0.1) [INFO] __cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse is now logged in
  Jan 10 14:20:10 cpanel pure-ftpd: (__cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse@127.0.0.1) [INFO] Logout.
  Jan 10 14:25:01 cpanel systemd: Started Session 11090 of user root.
  Jan 10 14:25:01 cpanel systemd: Started Session 11091 of user root.
  Jan 10 14:28:01 cpanel pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
  Jan 10 14:28:01 cpanel pure-ftpd: (?@127.0.0.1) [INFO] __cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse is now logged in
  Jan 10 14:28:01 cpanel pure-ftpd: (__cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse@127.0.0.1) [INFO] Logout.
  Jan 10 14:29:01 cpanel systemd: Started Session 11092 of user root.
  Jan 10 14:30:01 cpanel systemd: Started Session 11093 of user root.
  Jan 10 14:30:01 cpanel systemd: Started Session 11094 of user root.
  Jan 10 14:33:04 cpanel pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
  Jan 10 14:33:04 cpanel pure-ftpd: (?@127.0.0.1) [INFO] __cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse is now logged in
  Jan 10 14:33:04 cpanel pure-ftpd: (__cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse@127.0.0.1) [INFO] Logout.
  Jan 10 14:35:02 cpanel systemd: Started Session 11095 of user root.
  Jan 10 14:35:02 cpanel systemd: Started Session 11096 of user root.
  Jan 10 14:35:02 cpanel systemd: Started Session 11097 of user root.
  Jan 10 14:38:06 cpanel pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
  Jan 10 14:38:06 cpanel pure-ftpd: (?@127.0.0.1) [INFO] __cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse is now logged in
  Jan 10 14:38:06 cpanel pure-ftpd: (__cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse@127.0.0.1) [INFO] Logout.
  Jan 10 14:39:01 cpanel systemd: Started Session 11098 of user root.
  Jan 10 14:40:01 cpanel systemd: Started Session 11099 of user root.
  Jan 10 14:40:01 cpanel systemd: Started Session 11100 of user root.
  Jan 10 14:40:57 cpanel PAM-hulk[24100]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:41:00 cpanel PAM-hulk[24100]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:41:04 cpanel PAM-hulk[24100]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:41:07 cpanel PAM-hulk[24100]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:41:11 cpanel PAM-hulk[24100]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:41:14 cpanel PAM-hulk[24100]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:41:21 cpanel PAM-hulk[24110]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:43:09 cpanel pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
  Jan 10 14:43:09 cpanel pure-ftpd: (?@127.0.0.1) [INFO] __cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse is now logged in
  Jan 10 14:43:09 cpanel pure-ftpd: (__cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse@127.0.0.1) [INFO] Logout.
  Jan 10 14:44:01 cpanel systemd: Started Session 11101 of user root.
  Jan 10 14:45:01 cpanel systemd: Started Session 11102 of user root.
  Jan 10 14:48:12 cpanel pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
  Jan 10 14:48:12 cpanel pure-ftpd: (?@127.0.0.1) [INFO] __cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse is now logged in
  Jan 10 14:48:12 cpanel pure-ftpd: (__cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse@127.0.0.1) [INFO] Logout.
  Jan 10 14:50:01 cpanel systemd: Started Session 11103 of user root.
  Jan 10 14:50:01 cpanel systemd: Started Session 11105 of user root.
  Jan 10 14:50:01 cpanel systemd: Started Session 11104 of user root.
  Jan 10 14:53:14 cpanel pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
  Jan 10 14:53:14 cpanel pure-ftpd: (?@127.0.0.1) [INFO] __cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse is now logged in
  Jan 10 14:53:14 cpanel pure-ftpd: (__cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse@127.0.0.1) [INFO] Logout.
  Jan 10 14:55:01 cpanel systemd: Started Session 11106 of user root.
  Jan 10 14:55:12 cpanel PAM-hulk[24494]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:55:17 cpanel PAM-hulk[24494]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:55:21 cpanel PAM-hulk[24494]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:55:25 cpanel PAM-hulk[24494]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:55:29 cpanel PAM-hulk[24494]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:55:33 cpanel PAM-hulk[24494]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:55:42 cpanel PAM-hulk[24510]: Brute force detection active: 550 LOGIN DENIED -- TOO MANY FAILURES
  Jan 10 14:58:17 cpanel pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
  Jan 10 14:58:17 cpanel pure-ftpd: (?@127.0.0.1) [INFO] __cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse is now logged in
  Jan 10 14:58:17 cpanel pure-ftpd: (__cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse@127.0.0.1) [INFO] Logout.
  Jan 10 14:59:01 cpanel systemd: Started Session 11107 of user root.
  Jan 10 15:00:01 cpanel systemd: Started Session 11108 of user root.
  Jan 10 15:00:01 cpanel systemd: Started Session 11109 of user root.
  Jan 10 15:01:01 cpanel systemd: Started Session 11110 of user root.
  Jan 10 15:05:01 cpanel systemd: Started Session 11111 of user root.
  Jan 10 15:05:01 cpanel systemd: Started Session 11112 of user root.
  Jan 10 15:07:04 cpanel pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
  Jan 10 15:07:04 cpanel pure-ftpd: (?@127.0.0.1) [INFO] __cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse is now logged in
  Jan 10 15:07:04 cpanel pure-ftpd: (__cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse@127.0.0.1) [INFO] Logout.
  Jan 10 15:09:01 cpanel systemd: Started Session 11113 of user root.
  Jan 10 15:10:01 cpanel systemd: Started Session 11115 of user root.
  Jan 10 15:10:01 cpanel systemd: Started Session 11114 of user root.
  Jan 10 15:12:06 cpanel pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
  Jan 10 15:12:06 cpanel pure-ftpd: (?@127.0.0.1) [INFO] __cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse is now logged in
  Jan 10 15:12:06 cpanel pure-ftpd: (__cpanel__service__auth__ftpd__ZkeSALFUGDi7xNse@127.0.0.1) [INFO] Logout.
  Jan 10 15:14:01 cpanel systemd: Started Session 11116 of user root.
  </code></pre>
  
  <p>For that system log:</p>
  
  <p>Date and time format is:</p>
  
  <pre><code># date -d -1hour +%b" "%d" "%H:%M:%S
  Jan 10 14:16:03
  </code></pre>
  
  <p>For one hour ago:</p>
  
  <pre><code># date  +%b" "%d" "%H:%M:%S
  Jan 10 15:16:20
  </code></pre>
  
  <p>What am I missing here?.</p>