linux 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. [root@localhost ~]# vim /etc/logrotate.conf
  2. [root@localhost ~]# cd /etc/logrotate.d
  3. [root@localhost logrotate.d]# ls
  4. bootlog chrony firewalld syslog wpa_supplicant yum
  5. [root@localhost logrotate.d]# vim chrony
  6. [root@localhost logrotate.d]# vim xunwang
  7. /usr/local/src/nohup.out {
  8. daily
  9. rotate 15
  10. sharedscripts
  11. postrotate
  12. /bin/kill -HUP $(/bin/cat /var/run/syslogd.pid) &>/dev/null
  13. endscript
  14. }
  15. [root@localhost logrotate.d]# logrotate -vf /etc/logrotate.conf
  16. rotating pattern: /usr/local/src/nohup.out forced from command line (15 rotations)
  17. empty log files are rotated, old logs are removed
  18. considering log /usr/local/src/nohup.out
  19. log needs rotating
  20. rotating log /usr/local/src/nohup.out, log->rotateCount is 15
  21. dateext suffix '-20220523'
  22. glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
  23. glob finding old rotated logs failed
  24. fscreate context set to unconfined_u:object_r:usr_t:s0
  25. renaming /usr/local/src/nohup.out to /usr/local/src/nohup.out-20220523
  26. creating new /usr/local/src/nohup.out mode = 0600 uid = 0 gid = 0
  27. running postrotate script
  28. [root@localhost logrotate.d]# ps aux
  29. [root@localhost logrotate.d]# ps -le
  30. [root@localhost logrotate.d]# top
  31. top - 17:03:16 up 14 days, 1:15, 5 users, load average: 0.23, 0.19, 0.16
  32. Tasks: 167 total, 1 running, 163 sleeping, 3 stopped, 0 zombie
  33. %Cpu(s): 2.0 us, 2.4 sy, 0.0 ni, 95.6 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 s
  34. KiB Mem : 3564524 total, 1326808 free, 907764 used, 1329952 buff/cache
  35. KiB Swap: 8388604 total, 8388604 free, 0 used. 2382316 avail Mem
  36. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  37. 11375 root 20 0 159220 6028 4324 S 1.0 0.2 0:26.02 sshd
  38. 11572 root 20 0 162916 3076 1572 S 0.7 0.1 0:09.41 top
  39. 29422 root 20 0 159220 6036 4324 S 0.7 0.2 3:11.69 sshd
  40. 9 root 20 0 0 0 0 S 0.3 0.0 22:31.97 rcu_sched
  41. 439 root 20 0 0 0 0 S 0.3 0.0 11:16.57 xfsaild/+
  42. 525 root 20 0 16336 1348 1148 S 0.3 0.0 3:18.33 lldpad
  43. 4879 root 20 0 4774312 591344 24724 S 0.3 16.6 2:07.52 java
  44. [root@localhost logrotate.d]# top -p 4897
  45. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  46. 4897 root 20 0 4787676 594772 24732 S 0.3 16.7 2:13.33 Common-C+
  47. [root@localhost logrotate.d]# vmstat
  48. procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
  49. r b swpd free buff cache si so bi bo in cs us sy id wa st
  50. 1 0 0 1316272 2116 1332492 0 0 0 1 7 0 0 0 99 0 0
  51. [root@localhost logrotate.d]# free
  52. total used free shared buff/cache available
  53. Mem: 3564524 913488 1315288 39892 1335748 2376584
  54. Swap: 8388604 0 8388604