Friday, 9 October 2020

Logrotate with compress and delaycompress options.

Step1:-

[root@sankar ~]#  cat /etc/logrotate.d/sankar_myapp

/var/hvmail/log/myapp_event-processor/logfile.log {
    su root root
    rotate 7
    hourly
    compress
    delaycompress
}
[root@sankar ~]# 


Step2:- Dry run (-d) option

[root@sankar ~]# logrotate -d /etc/logrotate.d/sankar_myapp
...
....


Step3:- 
with the exception of the most recent one, should be compressed.


[root@sankar ~]# cd /var/hvmail/log/myapp_event-processor/ 

[root@sankar  myapp_event-processor]# ls -ltrh
total 28M
-rw-rwxr-x 1  root          root   23K Oct  9 09:03 logfile.log.2.gz
-rw-rwxr-x 1 root           root      421K Oct  9 10:06 logfile.log.1
-rw-rwxr-x 1 root           root      427K Oct  9 10:59 logfile.log


Tuesday, 14 July 2020

Shell script - how to Disable/Lock a list of users in Linux

Shell Script Examples

Linux Users:-  abc,  xyz, sankar, sai

Script:-
root@sankar:~#  for i in abc xyz sankar sai; do echo "Locking user $i" && passwd -l "$i" ; done

Locking user abc
Locking password for user abc.
passwd: Success
Locking user xyz
Locking password for user xyz.
passwd: Success
Locking user sankar
Locking password for user sankar.
passwd: Success
Locking user sai
Locking password for user sai.
passwd: Success