在日志文件中格式化日期并获取一小时日志

时间:2018-10-08 04:50:46

标签: shell awk sed grep

这是我在syslog上的日志格式:

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { OnInit } from '@angular/core/src/metadata/lifecycle_hooks';
import { Observable } from 'rxjs/internal/Observable';
import { User } from './user';
import 'rxjs/add/operator/map';

@Injectable(
  //providedIn: 'root'
)
export class SummaryService {
  public baseurl = 'https://jsonplaceholder.typicode.com/posts'
  constructor(private http: HttpClient) { }
  getUsers(): Observable<User[]> {
    return this.http.get<User[]>(this.baseurl);
  }
}

因此,当我使用以下命令获取10分钟以上的日志,其内容为已删除时。空了。

命令:

*Oct  8 09:27:40 local-ThinkPad-T430 anacron[18574]: Job `cron.daily' terminated
Oct  8 09:27:40 local-ThinkPad-T430 anacron[18574]: Normal exit (1 job run)
Oct  8 09:34:47 local-ThinkPad-T430 AptDaemon: INFO: Quitting due to inactivity
Oct  8 09:34:47 local-ThinkPad-T430 AptDaemon: INFO: Quitting was requested
Oct  8 09:34:47 local-ThinkPad-T430 org.debian.apt[959]: 09:34:47 AptDaemon [INFO]: Quitting due to inactivity
Oct  8 09:34:47 local-ThinkPad-T430 org.debian.apt[959]: 09:34:47 AptDaemon [INFO]: Quitting was requested
Oct  8 09:39:39 local-ThinkPad-T430 systemd[1534]: Time has been changed
Oct  8 09:39:39 local-ThinkPad-T430 systemd[1]: Time has been changed
Oct  8 09:39:39 local-ThinkPad-T430 systemd-timesyncd[375]: Synchronized to time server 91.189.91.157:123 (ntp.ubuntu.com).
Oct  8 09:55:09 local-ThinkPad-T430 postfix/pickup[18495]: E4AB41A2539: uid=1001 from=<local@local-ThinkPad-T430>
Oct  8 09:55:09 local-ThinkPad-T430 postfix/cleanup[23844]: E4AB41A2539: message-id=<20181008042509.E4AB41A2539@local-ThinkPad-T430>
Oct  8 09:55:10 local-ThinkPad-T430 postfix/qmgr[1678]: E4AB41A2539: from=<local@local-ThinkPad-T430>, size=402, nrcpt=1 (queue active)
Oct  8 09:55:10 local-ThinkPad-T430 postfix/cleanup[23844]: 1E10F1A25F6: message-id=<20181008042510.1E10F1A25F6@local-ThinkPad-T430>
Oct  8 09:55:10 local-ThinkPad-T430 postfix/bounce[23847]: E4AB41A2539: sender non-delivery notification: 1E10F1A25F6
Oct  8 09:55:10 local-ThinkPad-T430 postfix/qmgr[1678]: 1E10F1A25F6: from=<>, size=2305, nrcpt=1 (queue active)
Oct  8 09:55:10 local-ThinkPad-T430 postfix/qmgr[1678]: E4AB41A2539: removed
Oct  8 09:55:10 local-ThinkPad-T430 postfix/local[23846]: 1E10F1A25F6: to=<local@local-ThinkPad-T430>, relay=local, delay=0.12, delays=0.03\
/0/0/0.08, dsn=2.0.0, status=sent (delivered to mailbox)
Oct  8 09:55:10 local-ThinkPad-T430 postfix/qmgr[1678]: 1E10F1A25F6: removed
*

任何解决方案?

0 个答案:

没有答案